Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear electron-link's snapshot cache in script/clean #17603

merged 1 commit into from Jun 29, 2018


None yet
1 participant
Copy link

maxbrunsfeld commented Jun 29, 2018


When rebuilding master after c57c4b9 (which removed one of several instances of string_decoder in our dependencies) landed, I started getting this error at runtime:

Uncaught (in promise) Error: Cannot find module '../node_modules/string_decoder/index.js'
    at Module._resolveFilename (module.js:543:15)
    at Module._resolveFilename (/Applications/
    at Function.get_Module._resolveFilename (/Applications/
    at Module.require (file:///Applications/
    at require (internal/module.js:11:18)
    at customRequire (/Applications/<embedded>:96:26)
    at get_Decoder (/Applications/

The transformed source code of the split module was invalid, referencing a path in node_modules that was no longer present.

Description of the Change

This PR adds ~/.atom/snapshot-cache to the list of directories that should be cleared when running script/clean.


Electron link caches the result of transforming each source file with a key based on the source file's contents. But the output depends on more than just the source file's content - require paths are -pre-resolved based on the state of the file system. So when the content of the application's node_modules folder changes, previously cached transformations for unrelated source files can be rendered invalid.

This is a pretty rare occurrence, but when it does occur, running script/clean should ensure that we get a correct build again.

Possible Drawbacks

Maybe there's a way that we could make the caching logic more bulletproof, such that it would never give back stale data. This seems complex though, and the current situation works most of the time.

@maxbrunsfeld maxbrunsfeld merged commit ea9b7ce into master Jun 29, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

@maxbrunsfeld maxbrunsfeld deleted the mb-clear-snapshot-cache branch Jun 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.