Skip to content

Conversation

@leotm
Copy link
Contributor

@leotm leotm commented Mar 26, 2025

main(b9a3689)

Importing "@jridgewell/sourcemap-codec" was not allowed by policy builtins:undefined

lavamoat run -b metro
warning › Resolved metro → node_modules/metro/src/cli.js
info    › Entrypoint is in a node_modules/ directory and is considered untrusted
error   › Failed to load module "./src/cli.js" in package "file:///Users/leo/Documents/GitHub/metamask-mobile/node_modules/metro/" (2 underlying failures: Importing "@jridgewell/sourcemap-codec" was not allowed by policy builtins:undefined (info: Blocked in loading. "@jridgewell/sourcemap-codec" was not in the compartment map and an attempt was made to load it as a builtin), Importing "@jridgewell/sourcemap-codec" was not allowed by policy builtins:undefined (info: Blocked in loading. "@jridgewell/sourcemap-codec" was not in the compartment map and an attempt was made to load it as a builtin)
TypeError: Failed to load module "./src/cli.js" in package "file:///Users/leo/Documents/GitHub/metamask-mobile/node_modules/metro/" (2 underlying failures: Importing "@jridgewell/sourcemap-codec" was not allowed by policy builtins:undefined (info: Blocked in loading. "@jridgewell/sourcemap-codec" was not in the compartment map and an attempt was made to load it as a builtin), Importing "@jridgewell/sourcemap-codec" was not allowed by policy builtins:undefined (info: Blocked in loading. "@jridgewell/sourcemap-codec" was not in the compartment map and an attempt was made to load it as a builtin)
at throwAggregateError (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-load.js:557:11)
at load (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-load.js:605:3)
at async execute (file:///Users/leo/Documents/GitHub/LavaMoat/packages/node/src/exec/execute.js:90:25)
at async Object.handler (file:///Users/leo/Documents/GitHub/LavaMoat/packages/node/src/cli.js:478:9)

error › Cannot read properties of undefined (reading 'Symbol(graceful-fs.queue)')

lavamoat run -b metro
warning › Resolved metro → node_modules/metro/src/cli.js
info    › Entrypoint is in a node_modules/ directory and is considered untrusted
error   › Cannot read properties of undefined (reading 'Symbol(graceful-fs.queue)')
TypeError: Cannot read properties of undefined (reading 'Symbol(graceful-fs.queue)')
at Proxy.eval (file:///Users/leo/Documents/GitHub/metamask-mobile/node_modules/graceful-fs/graceful-fs.js:45:17)
at Object.execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs.js:56:13)
at execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-instance.js:101:24)
at compartmentImportNow (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/compartment.js:103:3)
at ExecutionCompartment.importNow (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/compartment.js:188:12)
at require (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs-shared-export-wrapper.js:166:31)
at Proxy.eval (file:///Users/leo/Documents/GitHub/metamask-mobile/node_modules/metro-file-map/src/cache/DiskCacheManager.js:10:17)
at Object.execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs.js:56:13)
at execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-instance.js:101:24)
at compartmentImportNow (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/compartment.js:103:3)

Importing "inherits" in "glob-v7.2.3"
could be better to output canonical name from policy instead of ver no.
Importing "inherits" in "rimraf>glob"


note: bumping ansi-styles to v6 needs to be done more carefully to fix the immutable export
but even better we have a fix in endo/compartment-mapper@1.6.0

yarn allow-scripts auto
yarn run v1.22.22
$ /Users/leo/Documents/GitHub/metamask-mobile/node_modules/.bin/allow-scripts auto
/Users/leo/Documents/GitHub/metamask-mobile/node_modules/wrap-ansi/index.js:4
const ansiStyles = require('ansi-styles');
                   ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/leo/Documents/GitHub/metamask-mobile/node_modules/ansi-styles/index.js from /Users/leo/Documents/GitHub/metamask-mobile/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /Users/leo/Documents/GitHub/metamask-mobile/node_modules/ansi-styles/index.js in /Users/leo/Documents/GitHub/metamask-mobile/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/leo/Documents/GitHub/metamask-mobile/node_modules/wrap-ansi/index.js:4:20) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.18.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

now they're imports
https://github.com/chalk/wrap-ansi/blob/main/index.js

import stringWidth from 'string-width';
import stripAnsi from 'strip-ansi';
import ansiStyles from 'ansi-styles';

// ...

@boneskull
Copy link

for the graceful-fs issue, see LavaMoat/LavaMoat#1581

for now, we can patch graceful-fs using patch-package as a workaround. see this patch

@leotm leotm force-pushed the lavamoat-node-metro branch from a234e99 to e732985 Compare April 14, 2025 15:03
@leotm
Copy link
Contributor Author

leotm commented Apr 14, 2025

➜  lavamoat run -b metro
warning › Resolved metro → node_modules/metro/src/cli.js
info    › Entrypoint is in a node_modules/ directory and is considered untrusted
error   › Cannot add property ___graceful-fs_queue, object is not extensible
TypeError: Cannot add property ___graceful-fs_queue, object is not extensible
at publishQueue (eval at <anonymous> (eval at makeEvaluate (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/make-evaluate.js:92:27)), <anonymous>:11:35)
at Proxy.eval (eval at <anonymous> (eval at makeEvaluate (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/make-evaluate.js:92:27)), <anonymous>:73:3)
at Object.execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs.js:56:13)
at execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-instance.js:101:24)
at compartmentImportNow (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/compartment.js:103:3)
at ExecutionCompartment.importNow (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/compartment.js:188:12)
at require (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs-shared-export-wrapper.js:157:31)
at Proxy.eval (eval at <anonymous> (eval at makeEvaluate (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/make-evaluate.js:92:27)), <anonymous>:10:19)
at Object.execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/@endo/compartment-mapper/src/parse-cjs.js:56:13)
at execute (file:///Users/leo/Documents/GitHub/LavaMoat/node_modules/ses/src/module-instance.js:101:24)

TODO: re-check copied graceful-fs.js patch

edit: can't repro, was likely caching

@leotm leotm force-pushed the lavamoat-node-metro branch from 680969a to d00db2a Compare April 14, 2025 15:57
@leotm
Copy link
Contributor Author

leotm commented Apr 14, 2025

spotted lavamoat generate -b metro generates a diff/new policy each time on LavaMoat/LavaMoat#1543 @boneskull (didn't notice it before), will it be resolved after LavaMoat/LavaMoat#1588 is merged first?

@sonarqubecloud
Copy link

@boneskull
Copy link

boneskull commented Apr 17, 2025

@leotm I can reproduce this

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues that have not had activity in the last 90 days label Jul 17, 2025
@github-actions
Copy link
Contributor

This PR was closed because there has been no follow up activity in 7 days. Thank you for your contributions.

@github-actions github-actions bot closed this Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template stale Issues that have not had activity in the last 90 days team-lavamoat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants