build
build copied to clipboard
Edge bundler crashes when attempting to run a module that uses a `sys` API.
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: https://github.com/netlify/cli/issues/6609
Possibly related deno
issue: https://github.com/denoland/deno/issues/22221
Steps to reproduce
- Clone reproduction repository: https://github.com/noelforte/netlify-deno-sys-repro
- Navigate to the cloned repository
-
npm install
- Run either
netlify build
ornetlify dev
- 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.5
❯ Flags
dry: false
offline: false
❯ Current directory
/Users/noel/Developer/projects/tests/netlify-dev-os
❯ Config file
/Users/noel/Developer/projects/tests/netlify-dev-os/netlify.toml
❯ Context
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/[email protected]/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/[email protected]/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/[email protected]/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