Skip to content

Commit 4e8a885

Browse files
[GR-33869] Backport: Do not print exceptions from Context.close() when terminating the process.
PullRequest: js/2160
2 parents 2b4e0df + 50a09fc commit 4e8a885

File tree

2 files changed

+9
-3
lines changed
  • graal-nodejs

2 files changed

+9
-3
lines changed

graal-nodejs/mx.graal-nodejs/com.oracle.truffle.trufflenode/src/com/oracle/truffle/trufflenode/GraalJSAccess.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,10 +3109,9 @@ public Object prepareStackTrace(JSRealm realm, DynamicObject error, DynamicObjec
31093109
private void exit(int status) {
31103110
try {
31113111
evaluator.close();
3112-
} catch (Throwable t) {
3113-
t.printStackTrace();
3112+
} finally {
3113+
System.exit(status);
31143114
}
3115-
System.exit(status);
31163115
}
31173116

31183117
public void isolateEnterPolyglotEngine(long callback, long isolate, long param1, long param2, long args, long execArgs) {

graal-nodejs/test/graal/unit/spawn.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,11 @@ describe('Spawn', function () {
113113
assert.strictEqual(result.status, 1);
114114
});
115115
}
116+
it('should finish gracefully when the process is terminated from an inner context', function () {
117+
var code = `require('vm').runInNewContext('process.exit()', { process: process })`;
118+
var result = spawnSync(process.execPath, ['-e', code]);
119+
assert.strictEqual(result.stdout.toString(), '');
120+
assert.strictEqual(result.stderr.toString(), '');
121+
assert.strictEqual(result.status, 0);
122+
});
116123
});

0 commit comments

Comments
 (0)