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

Error in nodejs: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize #432

Closed
arthabus opened this issue Dec 28, 2020 · 5 comments

Comments

@arthabus
Copy link

arthabus commented Dec 28, 2020

I was using source-maps for a bit on my nodejs server and it was working just fine. But now out of a sudden it started to crash with the below error when I try to create a SourceMapConsumer:

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
at readWasm (.../myNodeApp/functions/node_modules/source-map/lib/read-wasm.js:8:13)
at wasm (.../myNodeApp/functions/node_modules/source-map/lib/wasm.js:25:16)
at .../myNodeApp/functions/node_modules/source-map/lib/source-map-consumer.js:264:14
at runMicrotasks ()

Is this expected on node? I was never calling the initialize before and it seems like it's only required in browser?

Here is my code snippet:

const sourceMap = require('source-map'); //version "^0.7.3"

let contents = {...} //a json with a valid sourceMap content
let consumer = await new sourceMap.SourceMapConsumer(contents); //<- it now fails here with the above error

I've already tried to revert all my code back to when it was working but the error is still there.

Could anyone point me in the right direction on why this may be happening?

As a note, I've tried to provide the url as it's shown in the web browser usage page but it then fails with "response.arrayBuffer is not a function" internally while it tries to parse the file. I guess that happens because it wasn't able to download the file in the node environment in the first place, but again it seems like the problem is that it shouldn't ask for the url in node at all.

@arthabus
Copy link
Author

arthabus commented Dec 28, 2020

The problem I've faced was described here:

#349

Basically, the current source-map method of detecting environment is unreliable as it just checks if "fetch" function is declared to decide if it runs in web or in node.

Fixed the problem by switching to beta:

"source-map": "^0.8.0-beta.0",

Hopefully it would be pushed to stable sooner.

@bvaughn
Copy link

bvaughn commented Jun 15, 2021

Just got burned by this as well. Would be nice if this was released in a stable, given how long it's been. (Or that it was at least documented.)

@AntonyFagundez
Copy link

If somebody found this bug on cicd. In my team we found a way to fixed it.

In our case [email protected] resolve to [email protected] but this version breaks on github actions.


To resolve it, install it as dev dependency source-map, to resolve to 0.7.4

npm i source-map -D

AlbertoBrusa added a commit to AlbertoBrusa/modular that referenced this issue Nov 9, 2022
AlbertoBrusa added a commit to AlbertoBrusa/modular that referenced this issue Nov 9, 2022
cristiano-belloni pushed a commit to jpmorganchase/modular that referenced this issue Nov 22, 2022
* Add Node 18 to tests

* Add Node 18 to supported engines

* Pinned rollup-plugin-esbuild to 4.10.1 as newer versions drop support for node 14.17 and below

* Updated yarn.lock

* Update build.test snapshot

* Update modular-scripts snapshot

* Change rollup-plugin-eslint to latest compatible version

* Added changeset

* Update lockfile

* Resolve to source-map ^0.7.0 to try and fix mozilla/source-map#432

* Try to resolve v8-to-istanbul to fix mozilla/source-map#432

* Dropped support for Node 14.17.0 (14.18.0 and greater) to allow upgrate to rollup-plugin-eslint 5

* Update tests to use Node 14.18.0

* Make tests use Node 14.18.0

* update jest to 29

* change Node 16 supported version to 16.10+ as that's what Jest supports

* Upgrade to Jest 29 and fix problems caused by the upgrade

* Update changelog

* Update snapshots (default no longer includes escape characters etc)

* Update snapshots not to include espace caracters

* More snapshots updates

* Change env for port tests to Node

* Update snapshots and switch default test env to Node (while setting it to JSDOM for specific tests)

* Update more snapshots

* Remove broken Rename test (Rename functionality to be removed with Modular 4)

* Fix tests (test.test wasn't closing after running with the --watchAll flag, and adding __fixtures__ to the lint exception list made tests fail)

* Try to fix tests on Windows

* DEBUG windows tests

* Fix windows tests

* Try more things to fix tests

* More attempts to fix windows tests

* More desperate attempts to fix windows tests

* Clean up windows fix

* Cleanup

* Update changeset

* Set Jest watchAll default to false regardless of if CI or not

* Added ESLint ignore comments to svgr.ts for new TS complaints

* Documentation

* Update docs

* Add feature/v4 to branches to run CI Tests on (Needs to be reverted before merging to main)

* Small fixes

* Refactor out generateJestConfig flag logic to reduce duplication
cristiano-belloni added a commit to jpmorganchase/modular that referenced this issue Jan 23, 2023
* Node 18 & Jest 29 (#2210)

* Add Node 18 to tests

* Add Node 18 to supported engines

* Pinned rollup-plugin-esbuild to 4.10.1 as newer versions drop support for node 14.17 and below

* Updated yarn.lock

* Update build.test snapshot

* Update modular-scripts snapshot

* Change rollup-plugin-eslint to latest compatible version

* Added changeset

* Update lockfile

* Resolve to source-map ^0.7.0 to try and fix mozilla/source-map#432

* Try to resolve v8-to-istanbul to fix mozilla/source-map#432

* Dropped support for Node 14.17.0 (14.18.0 and greater) to allow upgrate to rollup-plugin-eslint 5

* Update tests to use Node 14.18.0

* Make tests use Node 14.18.0

* update jest to 29

* change Node 16 supported version to 16.10+ as that's what Jest supports

* Upgrade to Jest 29 and fix problems caused by the upgrade

* Update changelog

* Update snapshots (default no longer includes escape characters etc)

* Update snapshots not to include espace caracters

* More snapshots updates

* Change env for port tests to Node

* Update snapshots and switch default test env to Node (while setting it to JSDOM for specific tests)

* Update more snapshots

* Remove broken Rename test (Rename functionality to be removed with Modular 4)

* Fix tests (test.test wasn't closing after running with the --watchAll flag, and adding __fixtures__ to the lint exception list made tests fail)

* Try to fix tests on Windows

* DEBUG windows tests

* Fix windows tests

* Try more things to fix tests

* More attempts to fix windows tests

* More desperate attempts to fix windows tests

* Clean up windows fix

* Cleanup

* Update changeset

* Set Jest watchAll default to false regardless of if CI or not

* Added ESLint ignore comments to svgr.ts for new TS complaints

* Documentation

* Update docs

* Add feature/v4 to branches to run CI Tests on (Needs to be reverted before merging to main)

* Small fixes

* Refactor out generateJestConfig flag logic to reduce duplication

* Update to ESLint 8 & Supported TypeScript to >4.5.3 (#2216)

* Update ESLint to ^8.0.0, minimum Typescript to 4.5.3 & update dependencies

* Update changeset

* Fix warnings generated by updated ESLint

* Remove commands and update documentation (#2220)

* Remove commands and update documentation

* Update Readme & Changeset

* Merge main (#2225)

Merge changes to modular 3.x from main since feature/v4 was split out

* Use Config file instead of Environment Variables  (#2227)

* Use cosmiconfig to read modular configuration, while allowing Env variables to override it 

* Add configuration tests

* Change the default CDN to esm.sh

* Update documentation to reflect new configuration approach

* Use INTERNAL_ env variables to read configuration in JS files that can't call the config function

* Refactor config() logic 
Co-authored-by: Steve King <[email protected]>

* Add jsx to test glob pattern (#2234)

* Add jsx to test glob pattern

* Merge main into Modular 4 (#2237)

* Merge main into Modular 34

* Sunset modular-site

* Revert "Sunset modular-site"

This reverts commit a27388b.

* Sunset modular-site  (#2238)

* Sunset modular-site & update test snapshot

* Remove requirement for Apps to be private in modualr check (#2241)

* Update lockfile

* Docs/support (#2248)

* Initial cleanup

* Add compatibility page, remove recipes/yarn

* Better markdown section depth

* update nav order

* Document package types (#2246)

* Start documenting package types

* Describe App and ESM View types

* Packages

* Views, sources and templates

* Link add command page

* Link package types in index

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Link esm-views section in add page

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Link app section for more info

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Clarify manifest -> package.json + fix incorrect description

* Add reasons why we don't support things

* Disambiguate words

* Phrase 'default export' concept better

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Reword tricky sentence

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Split long sentence

* Add all package types to configuration docs

* Various typos

* Split packge types and move template page

* Fix links to package types and fix table layout

* Slim down table

* build/start/entrypoint/template sections

* Fix configuration

* Remove list of types in documentation

Co-authored-by: Sam Brown <[email protected]>

* Generate nicer READMEs inside new projects / apps / views / packages (#2253)

* Start documenting package types

* Describe App and ESM View types

* Packages

* Views, sources and templates

* Link add command page

* Link package types in index

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Link esm-views section in add page

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Link app section for more info

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Clarify manifest -> package.json + fix incorrect description

* Add reasons why we don't support things

* Disambiguate words

* Phrase 'default export' concept better

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Reword tricky sentence

* Update docs/commands/add.md

Co-authored-by: Sam Brown <[email protected]>

* Update docs/concepts/package-types.md

Co-authored-by: Sam Brown <[email protected]>

* Split long sentence

* Add all package types to configuration docs

* Various typos

* Split packge types and move template page

* Fix links to package types and fix table layout

* Slim down table

* build/start/entrypoint/template sections

* Add root project README

* Add per-package READMEs + fix docs

* Lint view documentation

* Update snapshots

* Upddate app snapshots

* Update snapshots in index test

* Update app.esbuild.test snapshots

* update cmra tests

* Correct snapshots for cmra

* Update snapshots for cli.test.ts

* Remove packages README + fix all READMEs

* Add README to fixtures + update snapshots

* Update various snapshots

* Update app.esbuild.test snapshots

* Add default workspace README

* Update index snapshots

* Create odd-bees-speak.md

* Update fixture READMEs

Co-authored-by: Sam Brown <[email protected]>
Co-authored-by: Alberto Brusa <[email protected]>

* Sunset philosophy / views, write intro, fix web workers, correct templates (#2254)

* Sunset philopsophy / views, move web workers, correct templates

* Better front page

* Fix command format

* Add web workers docs

* Enhance modular-scripts Tests (#2240)

* Update tests in modular-scripts to use tmp directories instead of changing things within the repo

* Consolidate all execa calls to yarn modular under one standardised function

* Change calls to modular during tests to not run checks 

* Refactor tests for brevity, code reuse and raedability 

* Remove unnecessary build snapshots from esmVies.test

* Modify getConfig to get workspace specific configuration (#2258)

* Modify getConfig to get workspace specific configuration

* Update config docs to reflect per workspace configuration

* Document supported CRA features (#2255)

* Rename limitations + start CRA page

* Add CRA supported features

* Fix typo

* Fixes in CRA page

* Test default template tests work (#2260)

* Unify modular test command interface (#2259)

* regex -> option, package -> argument

* Windows test use --package

* Remove space that fails test

* Add debug statement

* Implement selective testing and merging with user regexes

* Update docs

* Better wording

* Fix typo

* Test selective options combinations

* modular build builds all packages

* Test selective builds

* Document behaviour of modular build

* Create green-shrimps-build.md

* Fix test docs

* various docs fixes (#2262)

* Small fixes (#2261)

* Remove unnecessary error log

* Move jest-environment-jsdom to correct package.json

* Update typescript set by CMRA

* More small fixes (#2263)

* Remove unnecessary error log

* Move jest-environment-jsdom to correct package.json

* Remove jest-environment-jsdom from root package.json

* reorder dependencies

* v4.0.2

* v1.1.1

* v4.0.0

* Update typescript set by CMRA

* Revert accidentally changed versions and bump CMRA version by major due to update TS version

* Remove feature/v4 from GitHub Action tests & introduce forgotten CMRA changeset

* Update 4.0.x release notes

* Slight changes to release notes

* Additions to release doc

Co-authored-by: Cristiano Belloni <[email protected]>
Co-authored-by: Cristiano Belloni <[email protected]>
Co-authored-by: Sam Brown <[email protected]>
ca-d added a commit to apupier/open-scd that referenced this issue Mar 7, 2023
Adds a "source-map" dev dependency to package.json to fix the version to
one where mozilla/source-map#432 is not an
issue.
danyill pushed a commit to openscd/open-scd that referenced this issue Mar 13, 2023
* chore: Update Node from 14.x to 18.x

- updated GitHub Actions
- provide information in readme on the version to use

fixes #918

Signed-off-by: Aurélien Pupier <[email protected]>

* fix: explicitly depend on source-map

Adds a "source-map" dev dependency to package.json to fix the version to
one where mozilla/source-map#432 is not an
issue.

---------

Signed-off-by: Aurélien Pupier <[email protected]>
Co-authored-by: Christian Dinkel <[email protected]>
Co-authored-by: Sander Jansen <[email protected]>
@agarzola
Copy link

agarzola commented Oct 9, 2023

In case someone else runs into the issue we ran into recently: We use several packages that depend on source-map, each requiring a different minor version of this package:

Output of yarn why source-map
yarn why v1.22.17
[1/4] 🤔  Why do we have the module "source-map"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "source-map"
info Reasons this module exists
   - Hoisted from "gulp-sourcemaps#source-map"
   - Hoisted from "gulp-sourcemaps#@gulp-sourcemaps#identity-map#source-map"
   - Hoisted from "gulp-concat#concat-with-sourcemaps#source-map"
   - Hoisted from "gulp-sourcemaps#css#source-map"
   - Hoisted from "gulp-autoprefixer#postcss#source-map"
   - Hoisted from "gulp-clean-css#clean-css#source-map"
   - Hoisted from "gulp-uglify-es#terser#source-map-support#source-map"
info Disk size without dependencies: "796KB"
info Disk size with unique dependencies: "796KB"
info Disk size with transitive dependencies: "796KB"
info Number of shared dependencies: 0
=> Found "gulp-stylelint#[email protected]"
info This module exists because "gulp-stylelint" depends on it.
info Disk size without dependencies: "352KB"
info Disk size with unique dependencies: "352KB"
info Disk size with transitive dependencies: "352KB"
info Number of shared dependencies: 0
=> Found "vinyl-sourcemaps-apply#[email protected]"
info This module exists because "gulp-clean-css#vinyl-sourcemaps-apply" depends on it.
=> Found "snapdragon#[email protected]"
info This module exists because "braces#snapdragon" depends on it.
=> Found "terser#[email protected]"
info This module exists because "gulp-uglify-es#terser" depends on it.
info Disk size without dependencies: "352KB"
info Disk size with unique dependencies: "352KB"
info Disk size with transitive dependencies: "352KB"
info Number of shared dependencies: 0
=> Found "@babel/core#[email protected]"
info This module exists because "stylelint#@stylelint#postcss-css-in-js#@babel#core" depends on it.
=> Found "@babel/generator#[email protected]"
info This module exists because "stylelint#@stylelint#postcss-css-in-js#@babel#core#@babel#generator" depends on it.
✨  Done in 0.18s.

You might find, as we did, that simply adding a resolutions object to our package.json to resolve source-map to 0.7.4 (or 0.8.0-beta.0, for that matter) simply creates more problems because packages relying on 0.5.x and 0.6.x versions of source-map break when you try to use 0.7.x. What I didn’t realize for a day or two is that the broken release is 0.7.3, not every pre-0.7.4 release, so instead of resolving source-map to 0.7.4, we had to update our yarn.lock so that all 0.7.x versions are satisfied by 0.7.4 (where before they were satisfied by 0.7.3).

Frankly, I arrived at this solution by accident. After adding the resolutions line to package.json, running yarn install, and noticing the issue I described above, I removed the line and ran yarn install again, and found that we had a passing build. The resulting yarn.lock update looks like so:

 source-map@^0.7.3, source-map@~0.7.2:
-  version "0.7.3"
-  resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
-  integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
+  version "0.7.4"
+  resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656"
+  integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==

I hope this helps someone out there spend less time on this issue than I did! 😅

wmfgerrit pushed a commit to wikimedia/mediawiki-libs-Minify that referenced this issue Oct 29, 2023
Follows-up I60780a255997a in which I renamed file1.js to advanced.js,
which resulted in these two skipped tests.

This also fixes the verifySourceMap.js script which had stopped
working if you use Node 18 or later:

```
Error: You must provide the URL of lib/mappings.wasm by calling
SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
at readWasm (/node_modules/source-map/lib/read-wasm.js:8:13)
```

This was fixed in [email protected] per
<mozilla/source-map#432>.

Change-Id: I52140a0cd84a23da5efc7c361b203f850a26cc55
@ericmorand
Copy link

So, basically:

  • 0.6 definitions are wrong and prevent us from using the SourceNode::children method
  • 0.7 is buggy and doesn't work on brower runtimes
  • 0.8 has been on beta for...5 years

@loganfsmyth, is this project dead? Should we organize ourselves to take it over?

luwes added a commit to luwes/media-chrome that referenced this issue Feb 13, 2024
mikeharder added a commit to mikeharder/openapi-diff that referenced this issue Feb 16, 2024
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

No branches or pull requests

5 participants