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

fix(cli): don't store blob and data urls in the module cache #18261

Merged
merged 6 commits into from
Mar 26, 2023

Conversation

nayeemrmn
Copy link
Collaborator

Fixes #18260.
Also follows on from #18253.

ext/web/blob.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's a blob test for this already, but if not could you also test that importing the same blob URL in the same run twice gets the same module?

Something like this:

export let data = 3;
export const setData = d => { data = d; };

Create a blob out of that file, import it once, set data to 4, then import it a second time and verify that the data there is indeed 4.

I'm probably worrying for nothing, but seeing the cache drop out I thought that maybe, just maybe it would also mean that blob URL imports become unique instances.

@nayeemrmn
Copy link
Collaborator Author

I'm not sure if there's a blob test for this already, but if not could you also test that importing the same blob URL in the same run twice gets the same module?

Something like this:

export let data = 3;
export const setData = d => { data = d; };

maybe it would also mean that blob URL imports become unique instances.

@aapoalas I'm not sure what you're suggesting to test,

  • To check that it's the same instance we could just do await import(blobUrl) == await import(blobUrl), but that's an engine/deno_core guarantee which doesn't query CLI's module loader.
  • We could check that await import(blobUrl) and await import(blobUrl + "#1") give modules with the same behaviour... still seems esoteric. That implies the blob url might have been unbound after the first import for some reason (if anything that would occur right after creation leading to the first import failing).

Note that file URLs already opt out of FileFetcher's cache, it's a really high level one with like two beneath and one above it.

Actually, I've questioned why FileFetcher::cache is active for standard execution (e.g. run/test without --watch) given ProcState::graph_container. Pretty sure the only usage that really needs it is the LSP's ModuleRegistry. That would be a worthwhile investigation.

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was precisely referring to a test like await import(blobUrl) === await import(blobUrl) but if we already have prior examples of skipping the cache then it sounds safe enough a change to me.

Looks good to me and nice work! Very nice diff :)

@aapoalas aapoalas changed the title fix(cli): don't store blob urls in the module cache fix(cli): don't store blob and data urls in the module cache Mar 26, 2023
@aapoalas aapoalas merged commit b4c61c1 into denoland:main Mar 26, 2023
@nayeemrmn nayeemrmn deleted the blob-urls-no-module-cache branch March 26, 2023 13:42
@kt3k
Copy link
Member

kt3k commented Apr 3, 2023

Since this change, the islands in fresh don't build anymore, showing the below error (the error message is not that intelligible though). Maybe fresh was using these removed metadata?

✘ [ERROR] [unreachable] Not an ESM module. [plugin deno]

An error occurred during route handling or page rendering. Error: Build failed with 1 error:
error: [unreachable] Not an ESM module.
    at failureErrorWithLog (https://deno.land/x/[email protected]/mod.js:1612:15)
    at https://deno.land/x/[email protected]/mod.js:1024:25
    at runOnEndCallbacks (https://deno.land/x/[email protected]/mod.js:1447:45)
    at buildResponseToResult (https://deno.land/x/[email protected]/mod.js:1022:7)
    at https://deno.land/x/[email protected]/mod.js:1051:16
    at responseCallbacks.<computed> (https://deno.land/x/[email protected]/mod.js:673:9)
    at handleIncomingPacket (https://deno.land/x/[email protected]/mod.js:728:9)
    at readFromStdout (https://deno.land/x/[email protected]/mod.js:649:7)
    at https://deno.land/x/[email protected]/mod.js:1898:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Imported blob URLs are persisted in the FS module cache
4 participants