From 1cb8cc840e604a1529f6458e60039bf401761841 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 23 Dec 2025 17:16:17 -0800 Subject: [PATCH] Error if __async decorator applied to JS-only symbol The `__async` decorator marks JS function as async when they are imported into Wasm. It basically adds functions to `ASYNCIFY_IMPORTS`. It makes not sense to apply this decorator to a JS-only symbol. --- src/lib/libpthread.js | 3 --- src/utility.mjs | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/libpthread.js b/src/lib/libpthread.js index 54c2f913cdc32..aa3a59f69eb29 100644 --- a/src/lib/libpthread.js +++ b/src/lib/libpthread.js @@ -1077,9 +1077,6 @@ var LibraryPThread = { '$runtimeKeepaliveCounter', #endif ], -#if ASYNCIFY - $invokeEntryPoint__async: true, -#endif $invokeEntryPoint: {{{ asyncIf(ASYNCIFY == 2) }}}(ptr, arg) => { #if PTHREADS_DEBUG dbg(`invokeEntryPoint: ${ptrToString(ptr)}`); diff --git a/src/utility.mjs b/src/utility.mjs index f3ffa770118ba..d9123a12be99b 100644 --- a/src/utility.mjs +++ b/src/utility.mjs @@ -151,6 +151,13 @@ export function mergeInto(obj, other, options = null) { const decoratorName = key.slice(index); const type = typeof other[key]; + if (decoratorName == '__async') { + const decorated = key.slice(0, index); + if (isJsOnlySymbol(decorated)) { + error(`__async decorator applied to JS symbol: ${decorated}`); + } + } + // Specific type checking for `__deps` which is expected to be an array // (not just any old `object`) if (decoratorName === '__deps') {