diff --git a/tools/link.py b/tools/link.py index 57f32d09280e..969af7942a72 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1926,7 +1926,7 @@ def run_embind_gen(wasm_target, js_syms, extra_settings): if settings.MEMORY64: node_args += shared.node_memory64_flags() if settings.WASM_EXCEPTIONS: - node_args += shared.node_exception_flags() + node_args += shared.node_exception_flags(config.NODE_JS) # Run the generated JS file with the proper flags to generate the TypeScript bindings. out = shared.run_js_tool(outfile_js, [], node_args, stdout=PIPE) settings.restore(original_settings) diff --git a/tools/shared.py b/tools/shared.py index 77b7915636fc..562464abc2ab 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -397,8 +397,13 @@ def node_memory64_flags(): return ['--experimental-wasm-memory64'] -def node_exception_flags(): - return ['--experimental-wasm-eh'] +def node_exception_flags(nodejs): + node_version = get_node_version(nodejs) + # Exception handling was enabled by default in node v17. + if node_version and node_version < (17, 0, 0): + return ['--experimental-wasm-eh'] + else: + return [] def node_pthread_flags(nodejs):