File tree Expand file tree Collapse file tree 2 files changed +36
-26
lines changed
Expand file tree Collapse file tree 2 files changed +36
-26
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ require ( '../common' ) ;
4+ const tmpdir = require ( '../common/tmpdir' ) ;
5+ const assert = require ( 'assert' ) ;
6+ const { spawnSync } = require ( 'child_process' ) ;
7+ const fixtures = require ( '../common/fixtures' ) ;
8+ const fs = require ( 'fs' ) ;
9+ const env = {
10+ ...process . env ,
11+ NODE_DEBUG_NATIVE : 'diagnostics'
12+ } ;
13+
14+ {
15+ tmpdir . refresh ( ) ;
16+ const child = spawnSync ( process . execPath , [
17+ fixtures . path ( 'workload' , 'grow-worker.js' )
18+ ] , {
19+ cwd : tmpdir . path ,
20+ env : {
21+ TEST_SNAPSHOTS : 1 ,
22+ TEST_OLD_SPACE_SIZE : 50 ,
23+ ...env
24+ }
25+ } ) ;
26+ console . log ( child . stdout . toString ( ) ) ;
27+ const stderr = child . stderr . toString ( ) ;
28+ console . log ( stderr ) ;
29+ // There should be one snapshot taken and then after the
30+ // snapshot heap limit callback is popped, the OOM callback
31+ // becomes effective.
32+ assert ( stderr . includes ( 'ERR_WORKER_OUT_OF_MEMORY' ) ) ;
33+ const list = fs . readdirSync ( tmpdir . path )
34+ . filter ( ( file ) => file . endsWith ( '.heapsnapshot' ) ) ;
35+ assert . strictEqual ( list . length , 1 ) ;
36+ }
Original file line number Diff line number Diff line change @@ -86,29 +86,3 @@ const env = {
8686 . filter ( ( file ) => file . endsWith ( '.heapsnapshot' ) ) ;
8787 assert ( list . length > 0 && list . length <= 3 ) ;
8888}
89-
90-
91- {
92- console . log ( '\nTesting worker' ) ;
93- tmpdir . refresh ( ) ;
94- const child = spawnSync ( process . execPath , [
95- fixtures . path ( 'workload' , 'grow-worker.js' )
96- ] , {
97- cwd : tmpdir . path ,
98- env : {
99- TEST_SNAPSHOTS : 1 ,
100- TEST_OLD_SPACE_SIZE : 50 ,
101- ...env
102- }
103- } ) ;
104- console . log ( child . stdout . toString ( ) ) ;
105- const stderr = child . stderr . toString ( ) ;
106- console . log ( stderr ) ;
107- // There should be one snapshot taken and then after the
108- // snapshot heap limit callback is popped, the OOM callback
109- // becomes effective.
110- assert ( stderr . includes ( 'ERR_WORKER_OUT_OF_MEMORY' ) ) ;
111- const list = fs . readdirSync ( tmpdir . path )
112- . filter ( ( file ) => file . endsWith ( '.heapsnapshot' ) ) ;
113- assert . strictEqual ( list . length , 1 ) ;
114- }
You can’t perform that action at this time.
0 commit comments