{"record":{"id":"54488b90c4fa45a6","repo":"dotnet/runtime","slug":"invalid-jsthreadblockingmode","errorCode":null,"errorMessage":"Invalid jsThreadBlockingMode","messagePattern":"Invalid jsThreadBlockingMode","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/managed-exports.ts","lineNumber":273,"sourceCode":"        const arg2 = get_arg(args, 3);\n        set_arg_intptr(arg1, mono_wasm_main_thread_ptr() as any);\n\n        // sync with JSHostImplementation.Types.cs\n        switch (jsThreadBlockingMode) {\n            case JSThreadBlockingMode.PreventSynchronousJSExport:\n                set_arg_i32(arg2, 0);\n                break;\n            case JSThreadBlockingMode.ThrowWhenBlockingWait:\n                set_arg_i32(arg2, 1);\n                break;\n            case JSThreadBlockingMode.WarnWhenBlockingWait:\n                set_arg_i32(arg2, 2);\n                break;\n            case JSThreadBlockingMode.DangerousAllowBlockingWait:\n                set_arg_i32(arg2, 100);\n                break;\n            default:\n                throw new Error(\"Invalid jsThreadBlockingMode\");\n        }\n\n        // this block is like invoke_sync_jsexport() but without assert_js_interop()\n        cwraps.mono_wasm_invoke_jsexport(managedExports.InstallMainSynchronizationContext!, args);\n        if (is_args_exception(args)) {\n            const exc = get_arg(args, 0);\n            throw marshal_exception_to_js(exc);\n        }\n        return get_arg_gc_handle(res) as any;\n    } catch (e) {\n        mono_log_error(\"install_main_synchronization_context failed\", e);\n        throw e;\n    }\n}\n\nexport function invoke_async_jsexport (managedTID: PThreadPtr, method: MonoMethod, args: JSMarshalerArguments, size: number): void {\n    assert_js_interop();\n    if (!WasmEnableThreads || runtimeHelpers.isManagedRunningOnCurrentThread) {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/managed-exports.ts#L255-L291","documentation":"install_main_synchronization_context maps config.jsThreadBlockingMode to an integer via a switch that recognizes exactly four values (PreventSynchronousJSExport, ThrowWhenBlockingWait, WarnWhenBlockingWait, DangerousAllowBlockingWait). Any other value reaches the default branch and is rejected as invalid.","triggerScenarios":"Passing an unrecognized or misspelled string in config.jsThreadBlockingMode (e.g. 'PreventSync', 'Throw', a number, or undefined handling bypassed). The deputy thread calls install_main_synchronization_context with config.jsThreadBlockingMode at startup.","commonSituations":"Typo in the config object; copying a value from an older/newer version whose enum names differ; passing a numeric instead of the enum string.","solutions":["Set config.jsThreadBlockingMode to exactly one of: 'PreventSynchronousJSExport', 'ThrowWhenBlockingWait', 'WarnWhenBlockingWait', 'DangerousAllowBlockingWait'.","Omit the setting entirely so config.ts:203 applies the default 'PreventSynchronousJSExport'."],"exampleFix":"// before\nconfig.jsThreadBlockingMode = 'PreventSync';\n// after\nconfig.jsThreadBlockingMode = 'PreventSynchronousJSExport';","handlingStrategy":"validation","validationCode":"const VALID = new Set(['PreventSynchronousJSExport', 'ThrowWhenBlockingWait', 'WarnWhenBlockingWait', 'DangerousAllowBlockingWait']);\nif (config.jsThreadBlockingMode != null && !VALID.has(config.jsThreadBlockingMode)) {\n  throw new Error(`Invalid jsThreadBlockingMode '${config.jsThreadBlockingMode}'. Valid: ${[...VALID].join(', ')}`);\n}","typeGuard":"function isJSThreadBlockingMode(v): v is 'PreventSynchronousJSExport' | 'ThrowWhenBlockingWait' | 'WarnWhenBlockingWait' | 'DangerousAllowBlockingWait' {\n  return v === 'PreventSynchronousJSExport' || v === 'ThrowWhenBlockingWait' || v === 'WarnWhenBlockingWait' || v === 'DangerousAllowBlockingWait';\n}","tryCatchPattern":null,"preventionTips":["Use exactly one of the four documented enum string values, or omit the setting to get the default.","Validate config before passing it to the runtime rather than waiting for startup to throw."],"tags":["configuration","threading","startup"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}