| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c8a7789 commit 70768ce
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,6 +124,12 @@ const { | |||
| 124 | 124 | } = internalBinding('contextify'); | |
| 125 | 125 | ||
| 126 | 126 | const history = require('internal/repl/history'); | |
| 127 | + let nextREPLResourceNumber = 1; | ||
| 128 | + // This prevents v8 code cache from getting confused and using a different | ||
| 129 | + // cache from a resource of the same name | ||
| 130 | + function getREPLResourceName() { | ||
| 131 | + return `REPL${nextREPLResourceNumber++}`; | ||
| 132 | + } | ||
| 127 | 133 | ||
| 128 | 134 | // Lazy-loaded. | |
| 129 | 135 | let processTopLevelAwait; | |
@@ -541,10 +547,10 @@ function REPLServer(prompt, | |||
| 541 | 547 | if (e.name === 'SyntaxError') { | |
| 542 | 548 | // Remove stack trace. | |
| 543 | 549 | e.stack = e.stack | |
| 544 | - .replace(/^repl:\d+\r?\n/, '') | ||
| 550 | + .replace(/^REPL\d+:\d+\r?\n/, '') | ||
| 545 | 551 | .replace(/^\s+at\s.*\n?/gm, ''); | |
| 546 | 552 | } else if (self.replMode === exports.REPL_MODE_STRICT) { | |
| 547 | - e.stack = e.stack.replace(/(\s+at\s+repl:)(\d+)/, | ||
| 553 | + e.stack = e.stack.replace(/(\s+at\s+REPL\d+:)(\d+)/, | ||
| 548 | 554 | (_, pre, line) => pre + (line - 1)); | |
| 549 | 555 | } | |
| 550 | 556 | } | |
@@ -759,7 +765,7 @@ function REPLServer(prompt, | |||
| 759 | 765 | const evalCmd = self[kBufferedCommandSymbol] + cmd + '\n'; | |
| 760 | 766 | ||
| 761 | 767 | debug('eval %j', evalCmd); | |
| 762 | - self.eval(evalCmd, self.context, 'repl', finish); | ||
| 768 | + self.eval(evalCmd, self.context, getREPLResourceName(), finish); | ||
| 763 | 769 | ||
| 764 | 770 | function finish(e, ret) { | |
| 765 | 771 | debug('finish', e, ret); | |
@@ -1275,7 +1281,7 @@ function complete(line, callback) { | |||
| 1275 | 1281 | } | |
| 1276 | 1282 | ||
| 1277 | 1283 | const evalExpr = `try { ${expr} } catch {}`; | |
| 1278 | - this.eval(evalExpr, this.context, 'repl', (e, obj) => { | ||
| 1284 | + this.eval(evalExpr, this.context, getREPLResourceName(), (e, obj) => { | ||
| 1279 | 1285 | if (obj != null) { | |
| 1280 | 1286 | if (typeof obj === 'object' || typeof obj === 'function') { | |
| 1281 | 1287 | try { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const child_process = require('child_process'); | ||
| 5 | + const child = child_process.spawn(process.execPath, [ | ||
| 6 | + '--interactive', | ||
| 7 | + '--expose-gc' | ||
| 8 | + ], { | ||
| 9 | + stdio: 'pipe' | ||
| 10 | + }); | ||
| 11 | + child.stdin.write('\nimport("fs");\n_.then(gc);\n'); | ||
| 12 | + // Wait for concurrent GC to finish | ||
| 13 | + setTimeout(() => { | ||
| 14 | + child.stdin.write('\nimport("fs");\n'); | ||
| 15 | + child.stdin.write('\nprocess.exit(0);\n'); | ||
| 16 | + }, common.platformTimeout(50)); | ||
| 17 | + child.on('exit', (code, signal) => { | ||
| 18 | + assert.strictEqual(code, 0); | ||
| 19 | + assert.strictEqual(signal, null); | ||
| 20 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ const fixtures = require('../common/fixtures'); | |||
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const repl = require('repl'); | |
| 7 | 7 | ||
| 8 | - const stackRegExp = /repl:[0-9]+:[0-9]+/g; | ||
| 8 | + const stackRegExp = /(REPL\d+):[0-9]+:[0-9]+/g; | ||
| 9 | 9 | ||
| 10 | 10 | function run({ command, expected }) { | |
| 11 | 11 | let accum = ''; | |
@@ -25,8 +25,8 @@ function run({ command, expected }) { | |||
| 25 | 25 | ||
| 26 | 26 | r.write(`${command}\n`); | |
| 27 | 27 | assert.strictEqual( | |
| 28 | - accum.replace(stackRegExp, 'repl:*:*'), | ||
| 29 | - expected.replace(stackRegExp, 'repl:*:*') | ||
| 28 | + accum.replace(stackRegExp, '$1:*:*'), | ||
| 29 | + expected.replace(stackRegExp, '$1:*:*') | ||
| 30 | 30 | ); | |
| 31 | 31 | r.close(); | |
| 32 | 32 | } | |
@@ -48,8 +48,8 @@ const tests = [ | |||
| 48 | 48 | { | |
| 49 | 49 | // test .load for a file that throws | |
| 50 | 50 | command: `.load ${fixtures.path('repl-pretty-stack.js')}`, | |
| 51 | - expected: 'Uncaught Error: Whoops!--->\nrepl:*:*--->\nd (repl:*:*)' + | ||
| 52 | - '--->\nc (repl:*:*)--->\nb (repl:*:*)--->\na (repl:*:*)\n' | ||
| 51 | + expected: 'Uncaught Error: Whoops!--->\nREPL1:*:*--->\nd (REPL1:*:*)' + | ||
| 52 | + '--->\nc (REPL1:*:*)--->\nb (REPL1:*:*)--->\na (REPL1:*:*)\n' | ||
| 53 | 53 | }, | |
| 54 | 54 | { | |
| 55 | 55 | command: 'let x y;', | |
@@ -67,7 +67,7 @@ const tests = [ | |||
| 67 | 67 | // test anonymous IIFE | |
| 68 | 68 | { | |
| 69 | 69 | command: '(function() { throw new Error(\'Whoops!\'); })()', | |
| 70 | - expected: 'Uncaught Error: Whoops!--->\nrepl:*:*\n' | ||
| 70 | + expected: 'Uncaught Error: Whoops!--->\nREPL5:*:*\n' | ||
| 71 | 71 | } | |
| 72 | 72 | ]; | |
| 73 | 73 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ const fixtures = require('../common/fixtures'); | |||
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const repl = require('repl'); | |
| 7 | 7 | ||
| 8 | - const stackRegExp = /(at .*repl:)[0-9]+:[0-9]+/g; | ||
| 8 | + const stackRegExp = /(at .*REPL\d+:)[0-9]+:[0-9]+/g; | ||
| 9 | 9 | ||
| 10 | 10 | function run({ command, expected, ...extraREPLOptions }, i) { | |
| 11 | 11 | let accum = ''; | |
@@ -37,9 +37,9 @@ const tests = [ | |||
| 37 | 37 | { | |
| 38 | 38 | // Test .load for a file that throws. | |
| 39 | 39 | command: `.load ${fixtures.path('repl-pretty-stack.js')}`, | |
| 40 | - expected: 'Uncaught Error: Whoops!\n at repl:*:*\n' + | ||
| 41 | - ' at d (repl:*:*)\n at c (repl:*:*)\n' + | ||
| 42 | - ' at b (repl:*:*)\n at a (repl:*:*)\n' | ||
| 40 | + expected: 'Uncaught Error: Whoops!\n at REPL1:*:*\n' + | ||
| 41 | + ' at d (REPL1:*:*)\n at c (REPL1:*:*)\n' + | ||
| 42 | + ' at b (REPL1:*:*)\n at a (REPL1:*:*)\n' | ||
| 43 | 43 | }, | |
| 44 | 44 | { | |
| 45 | 45 | command: 'let x y;', | |
@@ -53,12 +53,12 @@ const tests = [ | |||
| 53 | 53 | { | |
| 54 | 54 | command: '(() => { const err = Error(\'Whoops!\'); ' + | |
| 55 | 55 | 'err.foo = \'bar\'; throw err; })()', | |
| 56 | - expected: "Uncaught Error: Whoops!\n at repl:*:* {\n foo: 'bar'\n}\n", | ||
| 56 | + expected: "Uncaught Error: Whoops!\n at REPL4:*:* {\n foo: 'bar'\n}\n", | ||
| 57 | 57 | }, | |
| 58 | 58 | { | |
| 59 | 59 | command: '(() => { const err = Error(\'Whoops!\'); ' + | |
| 60 | 60 | 'err.foo = \'bar\'; throw err; })()', | |
| 61 | - expected: 'Uncaught Error: Whoops!\n at repl:*:* {\n foo: ' + | ||
| 61 | + expected: 'Uncaught Error: Whoops!\n at REPL5:*:* {\n foo: ' + | ||
| 62 | 62 | "\u001b[32m'bar'\u001b[39m\n}\n", | |
| 63 | 63 | useColors: true | |
| 64 | 64 | }, | |
@@ -69,7 +69,7 @@ const tests = [ | |||
| 69 | 69 | // Test anonymous IIFE. | |
| 70 | 70 | { | |
| 71 | 71 | command: '(function() { throw new Error(\'Whoops!\'); })()', | |
| 72 | - expected: 'Uncaught Error: Whoops!\n at repl:*:*\n' | ||
| 72 | + expected: 'Uncaught Error: Whoops!\n at REPL7:*:*\n' | ||
| 73 | 73 | } | |
| 74 | 74 | ]; | |
| 75 | 75 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments