Repository navigation
lib,src: fix web storage crash in snapshot builder - #66884
Open
christianaurichzm wants to merge 1 commit into
Open
christianaurichzm wants to merge 1 commit into
christianaurichzm wants to merge 1 commit into
Conversation
The webstorage binding did not register its C++ callbacks as external references. A snapshot builder script that only reads `globalThis.localStorage` loads the binding, and serializing the snapshot then aborted with "Unknown external reference". Register them. Storage objects cannot be serialized, so creating `localStorage` or `sessionStorage` while building a snapshot now throws `ERR_NOT_SUPPORTED_IN_SNAPSHOT`, as creating a worker does. The web storage module also reads its options when a Storage is created rather than at load time, so a snapshot that loaded it still honors `--localstorage-file` passed at run time. The flag that limits the missing `--localstorage-file` warning to once is reset after the user's serialize callbacks, so a run from the snapshot still warns. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66884 +/- ##
==========================================
- Coverage 90.51% 90.49% -0.02%
==========================================
Files 797 797
Lines 278221 278399 +178
Branches 53463 53493 +30
==========================================
+ Hits 251844 251951 +107
- Misses 16763 16811 +48
- Partials 9614 9637 +23
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A snapshot builder script that reads
globalThis.localStorage,sessionStorageorStorageaborts the build:The webstorage binding never registers its C++ callbacks as external references, so once the getters load the binding the snapshot can't serialize the
Storagetemplate. Fixing only that is not enough forsessionStorage, because theStorageobject itself can't be serialized either.This registers the callbacks and makes creating
localStorageorsessionStoragewhile building a snapshot throwERR_NOT_SUPPORTED_IN_SNAPSHOT, likenew Worker()does.lib/internal/webstorage.jsalso read--localstorage-fileand the warning flag at load time, so a snapshot that touchedlocalStorageignored the file passed at run time and did not warn again. The options are now read in the getters, and the flag is reset when the snapshot is taken.test/parallel/test-snapshot-webstorage.jscovers both errors and the run-time case. It aborts without this change and passes with it.#66740 adds a webstorage
BindingDatathat is not serializable, so whichever of the two lands second will need to make it serializable. I haven't built them together yet.Refs: #66740