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: make EmitterFactory respect allow_remote_modules option when determining no npm mode #341

Merged
merged 1 commit into from
May 14, 2024

Conversation

nyannyacha
Copy link
Collaborator

@nyannyacha nyannyacha commented May 13, 2024

What kind of change does this PR introduce?

Enhancement

Description

This PR improves EmitterFactory so that it can determine no npm mode via the allowRemoteModules passed in by the user. (The original option for this is no_npm, but this is not exposed in js land).

// main service
await EdgeRuntime.userWorkers.create({
      servicePath,
      memoryLimitMb,
      workerTimeoutMs,
      noModuleCache,

      allowRemoteModules: false,
      ...
});

// some user script
import * as jose from 'npm:jose'
...

Output

...
DEBUG Snapshot already up to date. Skipping pending resolution.
failed to load 'npm:jose': npm specifiers were requested; but --no-npm is specified
An error has occured
InvalidWorkerCreation: worker boot error failed to load 'npm:jose': npm specifiers were requested; but --no-npm is specified
    at async UserWorker.create (ext:sb_user_workers/user_workers.js:155:15)
    at async createWorker (file:///workspaces/edge-runtime/examples/main/index.ts:85:12)
    at async callWorker (file:///workspaces/edge-runtime/examples/main/index.ts:104:22)
    at async respond (ext:sb_core_main_js/js/http.js:162:14) {
  name: "InvalidWorkerCreation"
}

Fixes #340

@nyannyacha nyannyacha merged commit d3d6d36 into supabase:main May 14, 2024
3 checks passed
@nyannyacha nyannyacha deleted the fix-no-remote branch May 14, 2024 01:13
Copy link

🎉 This PR is included in version 1.50.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Set allowRemoteModules=false can not prevent load remote npm packages with "npm:" specifier
2 participants