Skip to content

Commit 09f14b7

Browse files
committed
Update the minimum supported version of node (10.19.0 -> 16.20.0)
This new minimum version matches the version that we ship with emsdk. Critically it supports null coalescing & logical assignment needed by #20549. One side effect of this is that we no longer need to support the `NODEJS_CATCH_REJECTION` setting, which was needed only for node versions older than v15.
1 parent 1dedd1b commit 09f14b7

File tree

10 files changed

+22
-96
lines changed

10 files changed

+22
-96
lines changed

.circleci/config.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -721,18 +721,6 @@ jobs:
721721
core0.test_async_ccall_promise_jspi
722722
core0.test_async_ccall_promise_exit_runtime_jspi
723723
core0.test_cubescript_jspi"
724-
# Run some basic tests with the minimum version of node that we currently
725-
# support.
726-
- install-node-version:
727-
node_version: "10.19.0"
728-
- run-tests:
729-
title: "selected subset"
730-
test_targets: "
731-
other.test_gen_struct_info
732-
other.test_native_call_before_init
733-
other.test_node_unhandled_rejection
734-
other.test_full_js_library*
735-
core2.test_hello_world"
736724
# Run a few test with the most recent version of node
737725
# In particular we have some tests that require node flags on older
738726
# versions of node but not with the most recent version.

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.48 (in development)
2222
-----------------------
23+
- The minimum version of node required to run the compiler was updated from
24+
10.19.0 to 16.20.0. One side effect of this is that the
25+
`NODEJS_CATCH_REJECTION` settings no longer relevant and is will be ignored.
26+
(#20551)
2327
- A new top-level `bootstrap` script was added. This script is for emscripten
2428
developers and helps take a care of post-checkout tasks such as `npm install`.
2529
If this script needs to be run (e.g. becuase package.json was changed, emcc

emcc.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,6 @@ def make_js_executable(script):
747747
cmd = config.NODE_JS
748748
if settings.MEMORY64 == 1:
749749
cmd += shared.node_memory64_flags()
750-
elif settings.WASM_BIGINT:
751-
cmd += shared.node_bigint_flags()
752750
if len(cmd) > 1 or not os.path.isabs(cmd[0]):
753751
# Using -S (--split-string) here means that arguments to the executable are
754752
# correctly parsed. We don't do this by default because old versions of env
@@ -2276,23 +2274,20 @@ def phase_linker_setup(options, state, newargs):
22762274
if settings.MIN_CHROME_VERSION <= 37:
22772275
settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 1
22782276

2279-
# 10.19.0 is the oldest version of node that we do any testing with.
2277+
# 16.20.0 is the oldest version of node that we do any testing with.
22802278
# Keep this in sync with the test-node-compat in .circleci/config.yml
22812279
# and MINIMUM_NODE_VERSION in tools/shared.py
22822280
if settings.MIN_NODE_VERSION:
2283-
if settings.MIN_NODE_VERSION < 101900:
2284-
exit_with_error('targeting node older than 10.19.00 is not supported')
2285-
if settings.MIN_NODE_VERSION >= 150000:
2286-
default_setting('NODEJS_CATCH_REJECTION', 0)
2281+
if settings.MIN_NODE_VERSION < 162000:
2282+
exit_with_error('targeting node older than v16.2 is not supported')
22872283

22882284
# Do not catch rejections or exits in modularize mode, as these options
22892285
# are for use when running emscripten modules standalone
22902286
# see https://github.com/emscripten-core/emscripten/issues/18723#issuecomment-1429236996
22912287
if settings.MODULARIZE:
2292-
default_setting('NODEJS_CATCH_REJECTION', 0)
22932288
default_setting('NODEJS_CATCH_EXIT', 0)
2294-
if settings.NODEJS_CATCH_REJECTION or settings.NODEJS_CATCH_EXIT:
2295-
exit_with_error('Cannot use -sNODEJS_CATCH_REJECTION or -sNODEJS_CATCH_EXIT with -sMODULARIZE')
2289+
if settings.NODEJS_CATCH_EXIT:
2290+
exit_with_error('Cannot use -sNODEJS_CATCH_EXIT with -sMODULARIZE')
22962291

22972292
setup_environment_settings()
22982293

src/settings.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -756,16 +756,6 @@ var EXCEPTION_STACK_TRACES = false;
756756
// [link]
757757
var NODEJS_CATCH_EXIT = true;
758758

759-
// Catch unhandled rejections in node. This only effect versions of node older
760-
// than 15. Without this, old version node will print a warning, but exit
761-
// with a zero return code. With this setting enabled, we handle any unhandled
762-
// rejection and throw an exception, which will cause the process exit
763-
// immediately with a non-0 return code.
764-
// This not needed in Node 15+ so this setting will default to false if
765-
// MIN_NODE_VERSION is 150000 or above.
766-
// [link]
767-
var NODEJS_CATCH_REJECTION = true;
768-
769759
// Whether to support async operations in the compiled code. This makes it
770760
// possible to call JS functions from synchronous-looking code in C/C++.
771761
// 1: Run binaryen's Asyncify pass to transform the code using asyncify. This
@@ -1819,7 +1809,7 @@ var MIN_CHROME_VERSION = 75;
18191809
// distinct from the minimum version required run the emscripten compiler.
18201810
// This version aligns with the current Ubuuntu TLS 20.04 (Focal).
18211811
// Version is encoded in MMmmVV, e.g. 1814101 denotes Node 18.14.01.
1822-
var MIN_NODE_VERSION = 160000;
1812+
var MIN_NODE_VERSION = 162000;
18231813

18241814
// Tracks whether we are building with errno support enabled. Set to 0
18251815
// to disable compiling errno support in altogether. This saves a little
@@ -2167,4 +2157,5 @@ var LEGACY_SETTINGS = [
21672157
['USES_DYNAMIC_ALLOC', [1], 'No longer supported. Use -sMALLOC=none'],
21682158
['REVERSE_DEPS', ['auto', 'all', 'none'], 'No longer needed'],
21692159
['RUNTIME_LOGGING', 'RUNTIME_DEBUG'],
2160+
['NODEJS_CATCH_REJECTION', [0, 1], 'No longer applies to modern node versions'],
21702161
];

src/shell.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,6 @@ if (ENVIRONMENT_IS_NODE) {
245245
});
246246
#endif
247247

248-
#if NODEJS_CATCH_REJECTION
249-
// Without this older versions of node (< v15) will log unhandled rejections
250-
// but return 0, which is not normally the desired behaviour. This is
251-
// not be needed with node v15 and about because it is now the default
252-
// behaviour:
253-
// See https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
254-
var nodeMajor = process.versions.node.split(".")[0];
255-
if (nodeMajor < 15) {
256-
process.on('unhandledRejection', (reason) => { throw reason; });
257-
}
258-
#endif
259-
260248
quit_ = (status, toThrow) => {
261249
process.exitCode = status;
262250
throw toThrow;

test/common.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ def metafunc(self, with_bigint):
317317
if self.get_setting('WASM_BIGINT') is not None:
318318
self.skipTest('redundant in bigint test config')
319319
self.set_setting('WASM_BIGINT')
320-
self.node_args += shared.node_bigint_flags()
321320
f(self)
322321
else:
323322
f(self)
@@ -381,7 +380,6 @@ def metafunc(self, standalone):
381380
# if we are impure, disallow all wasm engines
382381
if impure:
383382
self.wasm_engines = []
384-
self.node_args += shared.node_bigint_flags()
385383
func(self)
386384

387385
metafunc._parameterize = {'': (False,),

test/test_core.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ def test_i64_varargs(self):
526526
def test_i64_invoke_bigint(self):
527527
self.set_setting('WASM_BIGINT')
528528
self.emcc_args += ['-fexceptions']
529-
self.node_args += shared.node_bigint_flags()
530529
self.do_core_test('test_i64_invoke_bigint.cpp')
531530

532531
def test_vararg_copy(self):
@@ -2287,7 +2286,6 @@ def test_em_js_i64(self):
22872286
self.assertContained('emcc: error: using 64-bit arguments in EM_JS function without WASM_BIGINT is not yet fully supported: `foo`', err)
22882287

22892288
self.set_setting('WASM_BIGINT')
2290-
self.node_args += shared.node_bigint_flags()
22912289
self.do_core_test('test_em_js_i64.c')
22922290

22932291
def test_em_js_address_taken(self):
@@ -7867,14 +7865,12 @@ def test_embind_dynamic_initialization(self):
78677865
def test_embind_i64_val(self):
78687866
self.set_setting('WASM_BIGINT')
78697867
self.emcc_args += ['-lembind']
7870-
self.node_args += shared.node_bigint_flags()
78717868
self.do_run_in_out_file_test('embind/test_i64_val.cpp', assert_identical=True)
78727869

78737870
@no_wasm2js('wasm_bigint')
78747871
def test_embind_i64_binding(self):
78757872
self.set_setting('WASM_BIGINT')
78767873
self.emcc_args += ['-lembind']
7877-
self.node_args += shared.node_bigint_flags()
78787874
self.do_run_in_out_file_test('embind/test_i64_binding.cpp', assert_identical=True)
78797875

78807876
def test_embind_no_rtti(self):
@@ -10038,8 +10034,7 @@ def setUp(self):
1003810034
require_wasm64=True)
1003910035
# MEMORY64=2, or "lowered"
1004010036
wasm64l = make_run('wasm64l', emcc_args=['-O1', '-Wno-experimental', '--profiling-funcs'],
10041-
settings={'MEMORY64': 2},
10042-
node_args=shared.node_bigint_flags())
10037+
settings={'MEMORY64': 2})
1004310038

1004410039
lto0 = make_run('lto0', emcc_args=['-flto', '-O0'])
1004510040
lto1 = make_run('lto1', emcc_args=['-flto', '-O1'])
@@ -10075,8 +10070,7 @@ def setUp(self):
1007510070
core2s = make_run('core2s', emcc_args=['-O2'], settings={'SAFE_HEAP': 1})
1007610071
core2ss = make_run('core2ss', emcc_args=['-O2'], settings={'STACK_OVERFLOW_CHECK': 2})
1007710072

10078-
bigint = make_run('bigint', emcc_args=['--profiling-funcs'], settings={'WASM_BIGINT': 1},
10079-
node_args=shared.node_bigint_flags())
10073+
bigint = make_run('bigint', emcc_args=['--profiling-funcs'], settings={'WASM_BIGINT': 1})
1008010074

1008110075
# Add DEFAULT_TO_CXX=0
1008210076
strict = make_run('strict', emcc_args=[], settings={'STRICT': 1})

test/test_other.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,12 +1010,6 @@ def test_failure_error_code(self):
10101010
self.expect_fail([compiler, test_file('hello_world.c'), 'this_file_is_missing.c', '-o', 'out.js'])
10111011
self.assertFalse(os.path.exists('out.js'))
10121012

1013-
def test_failure_modularize_and_catch_rejection(self):
1014-
for compiler in [EMCC, EMXX]:
1015-
# Test that if sMODULARIZE and sNODEJS_CATCH_REJECTION are both enabled, then emcc shouldn't succeed, and shouldn't produce an output file.
1016-
self.expect_fail([compiler, test_file('hello_world.c'), '-sMODULARIZE', '-sNODEJS_CATCH_REJECTION', '-o', 'out.js'])
1017-
self.assertFalse(os.path.exists('out.js'))
1018-
10191013
def test_failure_modularize_and_catch_exit(self):
10201014
for compiler in [EMCC, EMXX]:
10211015
# Test that if sMODULARIZE and sNODEJS_CATCH_EXIT are both enabled, then emcc shouldn't succeed, and shouldn't produce an output file.
@@ -7478,7 +7472,6 @@ def test_i64_return_value(self, args, bind_js):
74787472
''')
74797473

74807474
# Run the test and confirm the output is as expected.
7481-
self.node_args += shared.node_bigint_flags()
74827475
out = self.run_js('testrun.js')
74837476
self.assertContained('''\
74847477
input = 0xaabbccdd11223344
@@ -12676,7 +12669,7 @@ def test_config_closure_compiler(self):
1267612669
self.assertContained(sys.executable, err)
1267712670
self.assertContained('not execute properly!', err)
1267812671

12679-
def test_node_unhandled_rejection(self):
12672+
def test_unhandled_rejection(self):
1268012673
create_file('pre.js', '''
1268112674
async function foo() {
1268212675
var a = missing;
@@ -12695,24 +12688,11 @@ def test_node_unhandled_rejection(self):
1269512688
}
1269612689
''')
1269712690

12698-
# With NODEJS_CATCH_REJECTION we expect the unhandled rejection to cause a non-zero
12699-
# exit code and log the stack trace correctly.
12691+
# We expect the unhandled rejection to cause a non-zero exit code and log
12692+
# the stack trace correctly.
1270012693
self.build('main.c', emcc_args=['--pre-js=pre.js', '-sNODEJS_CATCH_REJECTION'])
1270112694
output = self.run_js('main.js', assert_returncode=NON_ZERO)
12702-
self.assertContained('unhandledRejection', read_file('main.js'))
12703-
self.assertContained('ReferenceError: missing is not defined', output)
12704-
self.assertContained('at foo (', output)
12705-
12706-
# Without NODEJS_CATCH_REJECTION we expect node to log the unhandled rejection
12707-
# but return 0.
12708-
self.node_args = [a for a in self.node_args if '--unhandled-rejections' not in a]
12709-
self.build('main.c', emcc_args=['--pre-js=pre.js', '-sNODEJS_CATCH_REJECTION=0'])
1271012695
self.assertNotContained('unhandledRejection', read_file('main.js'))
12711-
12712-
if shared.check_node_version()[0] >= 15:
12713-
self.skipTest('old behaviour of node JS cannot be tested on node v15 or above')
12714-
12715-
output = self.run_js('main.js')
1271612696
self.assertContained('ReferenceError: missing is not defined', output)
1271712697
self.assertContained('at foo (', output)
1271812698

@@ -12907,7 +12887,6 @@ def test_wasmfs_readfile(self):
1290712887
def test_wasmfs_readfile_bigint(self):
1290812888
self.set_setting('FORCE_FILESYSTEM')
1290912889
self.set_setting('WASM_BIGINT')
12910-
self.node_args += shared.node_bigint_flags()
1291112890
self.do_run_in_out_file_test(test_file('wasmfs/wasmfs_readfile.c'))
1291212891

1291312892
def test_wasmfs_jsfile(self):
@@ -13671,7 +13650,6 @@ def test_missing_struct_info(self):
1367113650
def run_wasi_test_suite_test(self, name):
1367213651
if not os.path.exists(path_from_root('test/third_party/wasi-test-suite')):
1367313652
self.fail('wasi-testsuite not found; run `git submodule update --init`')
13674-
self.node_args += shared.node_bigint_flags()
1367513653
wasm = path_from_root('test', 'third_party', 'wasi-test-suite', name + '.wasm')
1367613654
with open(path_from_root('test', 'third_party', 'wasi-test-suite', name + '.json')) as f:
1367713655
config = json.load(f)

tools/gen_struct_info.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ def inspect_headers(headers, cflags):
279279
# Run the compiled program.
280280
show('Calling generated program... ' + js_file[1])
281281
args = []
282-
if settings.MEMORY64:
283-
args += shared.node_bigint_flags()
284282
info = shared.run_js_tool(js_file[1], node_args=args, stdout=shared.PIPE).splitlines()
285283

286284
if not DEBUG:

tools/shared.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@
5252
PRINT_SUBPROCS = int(os.getenv('EMCC_VERBOSE', '0'))
5353
SKIP_SUBPROCS = False
5454

55-
# Minimum node version required to run the emscripten compiler. This is distinct
56-
# from the minimum version required to execute the generated code. This is not an
57-
# exact requirement, but is the oldest version of node that we do any testing with.
58-
# This version aligns with the current Ubuuntu TLS 20.04 (Focal).
59-
MINIMUM_NODE_VERSION = (10, 19, 0)
55+
# Minimum node version required to run the emscripten compiler. This is
56+
# distinct from the minimum version required to execute the generated code
57+
# (settings.MIN_NODE_VERSION).
58+
# This version currently matches the node version that we ship with emsdk
59+
# which means that we can say for sure that this version is well supported.
60+
MINIMUM_NODE_VERSION = (16, 20, 0)
6061
EXPECTED_LLVM_VERSION = 18
6162

6263
# These get set by setup_temp_dirs
@@ -351,15 +352,6 @@ def check_node_version():
351352
return version
352353

353354

354-
def node_bigint_flags():
355-
node_version = check_node_version()
356-
# wasm bigint was enabled by default in node v16.
357-
if node_version and node_version < (16, 0, 0):
358-
return ['--experimental-wasm-bigint']
359-
else:
360-
return []
361-
362-
363355
def node_reference_types_flags():
364356
node_version = check_node_version()
365357
# reference types were enabled by default in node v18.

0 commit comments

Comments
 (0)