lib: reset the cwd cache before execution
This diff attempts to reset the cwd cache before starting the script execution. This is necessary when a snapshot is used, as otherwise the cwd will be locked at the time of snapshot generate, until chdir
is called (that makes me wonder whether snapshots could lead to information leaks, if similar patterns are found in, say, process.env
?).
I'm not entirely sure whether adding a method to process.cwd
is the right approach - I suspected it was better than attempting to require
the file declaring the cwd cache (since it's a conditional branch), and moving the cwd cache to a dedicated file seemed a little overkill.
Fixes #49675 (closed)