-
Notifications
You must be signed in to change notification settings - Fork 231
node v18.0.0-nightly20220222c071bd581a's fetch()
breaks current sourcemap support
#2589
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
agent-nodejs
Make available for APM Agents project planning.
Comments
changes: mozilla/source-map@0.7.3...0.8.0-beta.0 |
I've opened rexxars/load-source-map#6 on the load-source-map repo that would fix this for us. Options:
|
Note to self to repro:
|
Option 3: This spectacularly awful hack: diff --git a/lib/stacktraces.js b/lib/stacktraces.js
index 3ea1b962..9f1540e9 100644
--- a/lib/stacktraces.js
+++ b/lib/stacktraces.js
@@ -14,7 +14,10 @@ const asyncCache = require('async-cache')
const afterAllResults = require('after-all-results')
const errorCallsites = require('error-callsites')
const errorStackParser = require('error-stack-parser')
+const _fetchCache = global.fetch
+if (_fetchCache !== undefined) delete global.fetch
const loadSourceMap = require('load-source-map')
+if (_fetchCache !== undefined) global.fetch = _fetchCache
const LRU = require('lru-cache')
const fileCache = asyncCache({ |
trentm
added a commit
that referenced
this issue
Mar 4, 2022
Recent node v18 turned on an implementation of `fetch()` by default. The 'source-map@0.7.3' dep used for sourcemap handling incorrectly uses the presence of `fetch` to decide it is in a browser env. This change inlines the load-source-map dep so we can update it to use the *beta* source-map@0.8.0-beta.0 which includes a fix. Fixes: #2589
trentm
added a commit
that referenced
this issue
Mar 5, 2022
Recent node v18 turned on an implementation of `fetch()` by default. The 'source-map@0.7.3' dep used for sourcemap handling incorrectly uses the presence of `fetch` to decide it is in a browser env. This change inlines the load-source-map dep so we can update it to use the *beta* source-map@0.8.0-beta.0 which includes a fix. Fixes: #2589
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
The node v18.0.0-nightly20220222c071bd581a release from a few days ago started breaking nightly tests (https://apm-ci.elastic.co/job/apm-agent-nodejs/job/apm-agent-nodejs-mbp/job/main/53/):
With verbose logging, the issue in the APM agent's usage of the
source-map
package is this:This is due to:
if (typeof fetch === "function")
to differentiate between browser and node.js environments: if (typeof fetch === "function") misidentifies node environment mozilla/source-map#349fetch
by default: lib: enable fetch by default nodejs/node#41811The same issue (broken source-map support) happened with early builds of node v18 when using the
--experimental-fetch
CLI option. The issue can be worked around in recent node v18 nightly builds by using the--no-experimental-fetch
CLI option.The same issue happens if
fetch()
is polyfilled, e.g. as Next.js does (according to discussion at GoogleChrome/workbox#2712).source-map
hasn't had a release since May 2018, before mozilla/source-map#349 was fixed. There is a beta release that could be considered:The text was updated successfully, but these errors were encountered: