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

Edge bundler crashes when attempting to run a module that uses a sys API. #5640

Open
noelforte opened this issue May 16, 2024 · 0 comments
Open
Labels
type: bug code to address defects in shipped code

Comments

@noelforte
Copy link

Describe the bug

This issue stems from a permissions issue that can be reproduced both in netlify dev and netlify build sub commands. When invoking a module that either makes a call to a node OS API.

Related CLI issue: netlify/cli#6609

Possibly related deno issue: denoland/deno#22221

Steps to reproduce

  1. Clone reproduction repository: https://github.com/noelforte/netlify-deno-sys-repro
  2. Navigate to the cloned repository
  3. npm install
  4. Run either netlify build or netlify dev
  5. See CLI output

CLI command and flags

netlify build

- or -

netlify dev

Configuration

(Bug is reproducible without a config file.)

CLI output

netlify build
Netlify Build
────────────────────────────────────────────────────────────────Version
  @netlify/build 29.41.5Flags
  dry: false
  offline: falseCurrent directory
  /Users/noel/Developer/projects/tests/netlify-dev-osConfig file
  /Users/noel/Developer/projects/tests/netlify-dev-os/netlify.tomlContext
  production

Functions bundling
────────────────────────────────────────────────────────────────


(Functions bundling completed in 2ms)

Edge Functions bundling
────────────────────────────────────────────────────────────────

Packaging Edge Functions from netlify/edge-functions directory:
 - glob

Save updated config
────────────────────────────────────────────────────────────────


(options.onEnd completed in 2ms)

Bundling of edge function failed
────────────────────────────────────────────────────────────────

  Error message
  There was an error when loading the 'fast-glob' npm module. Support for npm modules in edge functions is an experimental feature. Refer to https://ntl.fyi/edge-functions-npm for more information.

  Error location
  While bundling edge function

  Resolved config
  build:
    commandOrigin: heuristics
    edge_functions: ***/netlify-dev-os/netlify/edge-functions
    publish: ***/netlify-dev-os
    publishOrigin: default
netlify dev
◈ Netlify Dev ◈
◈ Injecting environment variable values for all scopes
◈ Ignored general context env var: LANG (defined in process)
◈ No app server detected. Using simple static server
◈ Running static server from "netlify-dev-os/dist"
◈ Setting up local development server
Cleaned up .netlify/functions-internal, .netlify/edge-functions.

◈ Static server listening to 3999

   ┌─────────────────────────────────────────────────┐
   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │
   └─────────────────────────────────────────────────┘

PermissionDenied: Requires sys access to "cpus", run again with the --allow-sys flag
    at Object.cpus (node:os:27:10)
    at Object.<anonymous> (file:///opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/.deno/fast-glob@3.3.2/node_modules/fast-glob/out/settings.js:10:31)
    at Object.<anonymous> (file:///opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/.deno/fast-glob@3.3.2/node_modules/fast-glob/out/settings.js:61:4)
    at Module._compile (node:module:659:34)
    at Object.Module._extensions..js (node:module:673:10)
    at Module.load (node:module:597:32)
    at Function.Module._load (node:module:484:12)
    at Module.require (node:module:609:19)
    at require (node:module:715:16)
    at Object.<anonymous> (file:///opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/.deno/fast-glob@3.3.2/node_modules/fast-glob/out/index.js:6:20) {
  name: "PermissionDenied"
}

Environment

  System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.06 GB / 32.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 22.1.0 - /opt/homebrew/bin/node
    npm: 10.8.0 - /opt/homebrew/bin/npm
    pnpm: 9.1.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.8 - ~/.bun/bin/bun
  npmGlobalPackages:
    netlify-cli: 17.23.5
@noelforte noelforte added the type: bug code to address defects in shipped code label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

1 participant