Skip to content

src: disallow calling env-dependent methods during bootstrap

These cannot be preserved correctly in v8 snapshot. Currently none of these are called during bootstrap, this adds assertions to make sure future contributors do not accidentally call these in the wrong time.

Consider this, on the machine that builds releases:

process.cwd();  // "/home/iojs/build/workspace/"

User downloads this binary to their machine:

$ cd ~/
$ pwd  # "/User/foo"
$ node -p "process.cwd()" # Cached "/home/iojs/build/workspace/"

This patch only adds checks in methods that get states from the environment - it's not likely that the setters would be called during bootstrap, and if they are called, we'll just ignore them and whatever tests that test the change would fail when snapshot is enabled. However the getters may be called in order to persist information into strings and that would be harder to catch (the test is only likely to test the format of these strings which won't be useful).

Refs: https://github.com/nodejs/node/pull/27224

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Merge request reports

Loading