From 830b8a40cb5df665ef9688bd7ac6cece3b1f4223 Mon Sep 17 00:00:00 2001 From: seke Date: Mon, 25 Nov 2019 15:04:21 +0100 Subject: [PATCH 1/6] Update source-map to 0.7.3 source-map 0.7.0+ has a much faster Rust WASM implementation. Because this needs to be loaded, the constructor is now asynchronous. The consumer should also be destroyed after it's no longer needed. --- scripts/dev-bundle-tool-package.js | 2 +- tools/fs/files.ts | 7 +++++-- tools/isobuild/import-scanner.ts | 3 ++- tools/isobuild/linker.js | 7 +++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/dev-bundle-tool-package.js b/scripts/dev-bundle-tool-package.js index 3490ab593d..9578f054ad 100644 --- a/scripts/dev-bundle-tool-package.js +++ b/scripts/dev-bundle-tool-package.js @@ -39,7 +39,7 @@ var packageJson = { // Fork of kexec@3.0.0 with my Node.js 12 compatibility PR // https://github.com/jprichardson/node-kexec/pull/37 applied. kexec: "https://github.com/meteor/node-kexec/tarball/f29f54037c7db6ad29e1781463b182e5929215a0", - "source-map": "0.5.7", + "source-map": "0.7.3", chalk: "0.5.1", sqlite3: "4.1.0", "http-proxy": "1.16.2", diff --git a/tools/fs/files.ts b/tools/fs/files.ts index 5df5b6eb16..d5538b0ba3 100644 --- a/tools/fs/files.ts +++ b/tools/fs/files.ts @@ -1164,8 +1164,10 @@ export function runJavaScript(code: string, { const header = "(function(" + keys.join(',') + "){"; chunks.push(header); if (sourceMap) { + const sourcemapConsumer = Promise.await(new sourcemap.SourceMapConsumer(sourceMap)); chunks.push(sourcemap.SourceNode.fromStringWithSourceMap( - code, new sourcemap.SourceMapConsumer(sourceMap))); + code, sourcemapConsumer)); + sourcemapConsumer.destroy(); } else { chunks.push(code); } @@ -1234,8 +1236,9 @@ export function runJavaScript(code: string, { if (parsedSourceMap) { // XXX this duplicates code in computeGlobalReferences - var consumer2 = new sourcemap.SourceMapConsumer(parsedSourceMap); + var consumer2 = Promise.await(new sourcemap.SourceMapConsumer(parsedSourceMap)); var original = consumer2.originalPositionFor(parseError.loc); + consumer2.destroy(); if (original.source) { err.file = original.source; err.line = original.line; diff --git a/tools/isobuild/import-scanner.ts b/tools/isobuild/import-scanner.ts index b4377f95dc..d70625c661 100644 --- a/tools/isobuild/import-scanner.ts +++ b/tools/isobuild/import-scanner.ts @@ -693,12 +693,13 @@ export default class ImportScanner { function getChunk(file: File) { const consumer = file.sourceMap && - new SourceMapConsumer(file.sourceMap); + Promise.await(new SourceMapConsumer(file.sourceMap)); const node = consumer && SourceNode.fromStringWithSourceMap( scanner.getDataString(file), consumer ); + consumer.destroy(); return node || scanner.getDataString(file); } diff --git a/tools/isobuild/linker.js b/tools/isobuild/linker.js index 9dfaa5f3c6..2450ca09f7 100644 --- a/tools/isobuild/linker.js +++ b/tools/isobuild/linker.js @@ -657,7 +657,7 @@ _.extend(File.prototype, { column: e.column }; if (self.sourceMap) { - var parsed = new sourcemap.SourceMapConsumer(self.sourceMap); + var parsed = Promise.await(new sourcemap.SourceMapConsumer(self.sourceMap)); var original = parsed.originalPositionFor( {line: e.lineNumber, column: e.column - 1}); if (original.source) { @@ -665,6 +665,7 @@ _.extend(File.prototype, { errorOptions.line = original.line; errorOptions.column = original.column + 1; } + parsed.destroy(); } buildmessage.error(e.message, errorOptions); @@ -779,10 +780,12 @@ const getPrelinkedOutputCached = require("optimism").wrap( let chunk = result.code; if (result.map) { + const sourcemapConsumer = Promise.await(new sourcemap.SourceMapConsumer(result.map)); chunk = sourcemap.SourceNode.fromStringWithSourceMap( result.code, - new sourcemap.SourceMapConsumer(result.map), + sourcemapConsumer, ); + sourcemapConsumer.destroy(); } chunks.push(chunk); From c37bab64a4750eafbc6483ee82f67e6ff6221029 Mon Sep 17 00:00:00 2001 From: seke Date: Mon, 25 Nov 2019 16:03:47 +0100 Subject: [PATCH 2/6] Fix fatal error with wasm gc and node-fibers in node 12.11+ https://github.com/nodejs/node/issues/29767 --- meteor | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meteor b/meteor index d201c5b2a0..7e5574d4c4 100755 --- a/meteor +++ b/meteor @@ -132,7 +132,10 @@ fi # the script take precedence over $NODE_PATH; it used to be that users would # screw up their meteor installs by have a ~/node_modules +# --no-wasm-code-gc is currently necessary as a workaround for +# https://github.com/nodejs/node/issues/29767 exec "$DEV_BUNDLE/bin/node" \ --max-old-space-size=4096 \ + --no-wasm-code-gc \ ${TOOL_NODE_FLAGS} \ "$METEOR" "$@" From bb1c8f2bdcfafa9fa042e6cd2caf0a0ed589b9a1 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Nov 2019 14:27:10 -0500 Subject: [PATCH 3/6] Bump $BUNDLE_VERSION to 12.13.0.2 before rebuilding dev bundle. --- meteor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meteor b/meteor index 7e5574d4c4..c4d6a27e35 100755 --- a/meteor +++ b/meteor @@ -1,6 +1,6 @@ #!/usr/bin/env bash -BUNDLE_VERSION=12.13.0.1 +BUNDLE_VERSION=12.13.0.2 # OS Check. Put here because here is where we download the precompiled # bundles that are arch specific. From 962ed18bb4d9831093c85fb17f1a75332d3950bd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Nov 2019 14:27:16 -0500 Subject: [PATCH 4/6] Pass --no-wasm-code-gc to node.exe in meteor.bat (Windows). --- meteor.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/meteor.bat b/meteor.bat index 6ea71fbe56..aa6b05d750 100644 --- a/meteor.bat +++ b/meteor.bat @@ -47,6 +47,7 @@ SET NODE_PATH=%~dp0\dev_bundle\lib\node_modules SET BABEL_CACHE_DIR=%~dp0\.babel-cache "%~dp0\dev_bundle\bin\node.exe" ^ + --no-wasm-code-gc ^ %TOOL_NODE_FLAGS% ^ "%~dp0\tools\index.js" %* From 34ada3f791fa9d6341a59eb1effce5eabb362a02 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Nov 2019 14:36:26 -0500 Subject: [PATCH 5/6] Declare type of Promise.await in tools/index.d.ts. --- tools/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/index.d.ts b/tools/index.d.ts index 62c834e501..73ead4e9d5 100644 --- a/tools/index.d.ts +++ b/tools/index.d.ts @@ -10,7 +10,13 @@ declare global { // This is an incomplete list of methods added to Promise.prototype by the // meteor-promise npm package. TODO Eventually these declarations should be // moved into that package. - await: () => T; + await(): T; + } + + // Promise.await(x) is a shorthand provided by meteor-promise for + // Promise.resolve(x).await(). + interface PromiseConstructor { + await(arg: T | PromiseLike): T; } interface Function { From a87e9116e67c9896d5799be18eeb95af16f7cde2 Mon Sep 17 00:00:00 2001 From: seke Date: Tue, 26 Nov 2019 21:00:48 +0100 Subject: [PATCH 6/6] Fix old-style tests --- tools/tests/old.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tests/old.js b/tools/tests/old.js index a69d5d58f4..775747c863 100644 --- a/tools/tests/old.js +++ b/tools/tests/old.js @@ -27,7 +27,7 @@ var runOldTest = function (filename, extraEnv) { var run = new Run(files.convertToStandardPath(process.execPath), { // 'args' are treated as-is, so need to be converted before passing into // 'Run' - args: [files.convertToOSPath(files.pathResolve( + args: ['--no-wasm-code-gc', files.convertToOSPath(files.pathResolve( files.convertToStandardPath(__dirname), 'old', filename))], env: maybeFixRelease(_.extend({ METEOR_TOOL_PATH: s.execPath