lib: account for cwd access from snapshot serialization cb
requested to merge github/fork/addaleax/snapshot-cwd-accessed-from-inside-serialize-callback into main
Functions registered with addSerializeCallback()
can access and call process.cwd()
. b7d836e2 accounted for the fact that it is necessary to reset the cwd cache after the snapshot builder script has run, but did not account for possible accesses from serialization callbacks. To properly account for these, add a deserialization callback as well.
As a related drive-by fix, also mention the execution order of callbacks in the documentation.