diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index fb895bd2b7..5464fcff94 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use") option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading") if(NOT WEBKIT_VERSION) - set(WEBKIT_VERSION c4d4cae03ecef2791f7ad5dd795f722d8be87d41) + set(WEBKIT_VERSION 5ae5f07f29059c183a8db2eef2c9aabd474ec73c) endif() string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX) diff --git a/scripts/buildkite-failures.ts b/scripts/buildkite-failures.ts index 4bc0bb5eca..4ee7e66033 100755 --- a/scripts/buildkite-failures.ts +++ b/scripts/buildkite-failures.ts @@ -215,7 +215,12 @@ while (true) { } // Check if build is pending/running/scheduled - if (build.state === "scheduled" || build.state === "running" || build.state === "creating") { + if ( + build.state === "scheduled" || + build.state === "running" || + build.state === "creating" || + build.state === "started" + ) { const runningJobs = build.jobs?.filter((job: any) => job.state === "running") || []; const pendingJobs = build.jobs?.filter((job: any) => job.state === "scheduled" || job.state === "waiting") || []; const passedJobs = build.jobs?.filter((job: any) => job.state === "passed") || []; diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp index f78856281a..05db73662e 100644 --- a/src/bun.js/bindings/BunObject.cpp +++ b/src/bun.js/bindings/BunObject.cpp @@ -959,7 +959,7 @@ static void exportBunObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC: JSValue value = object->get(globalObject, propertyName); if (catchScope.exception()) { - catchScope.clearException(); + (void)catchScope.tryClearException(); value = jsUndefined(); } exportValues.append(value); diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp index 590037d1a5..218b836e0e 100644 --- a/src/bun.js/bindings/BunPlugin.cpp +++ b/src/bun.js/bindings/BunPlugin.cpp @@ -546,7 +546,7 @@ extern "C" JSC_DEFINE_HOST_FUNCTION(JSMock__jsModuleMock, (JSC::JSGlobalObject * auto catchScope = DECLARE_CATCH_SCOPE(vm); auto result = JSValue::decode(Bun__resolveSyncWithSource(globalObject, JSValue::encode(specifierString), &from, true, false)); if (catchScope.exception()) { - catchScope.clearException(); + (void)catchScope.tryClearException(); } if (result && result.isString()) { @@ -649,7 +649,7 @@ extern "C" JSC_DEFINE_HOST_FUNCTION(JSMock__jsModuleMock, (JSC::JSGlobalObject * auto catchScope = DECLARE_CATCH_SCOPE(vm); JSValue value = object->get(globalObject, name); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); value = jsUndefined(); } moduleNamespaceObject->overrideExportValue(globalObject, name, value); diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index f0e77d579c..907682c237 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -1203,7 +1203,7 @@ extern "C" int Bun__handleUncaughtException(JSC::JSGlobalObject* lexicalGlobalOb auto scope = DECLARE_CATCH_SCOPE(vm); (void)call(lexicalGlobalObject, capture, args, "uncaughtExceptionCaptureCallback"_s); if (auto ex = scope.exception()) { - scope.clearException(); + (void)scope.tryClearException(); // if an exception is thrown in the uncaughtException handler, we abort Bun__logUnhandledException(JSValue::encode(JSValue(ex))); Bun__Process__exit(lexicalGlobalObject, 1); @@ -2355,7 +2355,7 @@ static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, JSC: auto result = JSC::profiledCall(globalObject, ProfilingReason::API, getStdioWriteStream, callData, globalObject->globalThis(), args); if (auto* exception = scope.exception()) { Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); - scope.clearException(); + (void)scope.tryClearException(); return jsUndefined(); } @@ -2416,7 +2416,7 @@ static JSValue constructStdin(VM& vm, JSObject* processObject) auto result = JSC::profiledCall(globalObject, ProfilingReason::API, getStdinStream, callData, globalObject, args); if (auto* exception = scope.exception()) { Zig::GlobalObject::reportUncaughtExceptionAtEventLoop(globalObject, exception); - scope.clearException(); + (void)scope.tryClearException(); return jsUndefined(); } return result; diff --git a/src/bun.js/bindings/CallSite.cpp b/src/bun.js/bindings/CallSite.cpp index 158049649e..4fe20ab069 100644 --- a/src/bun.js/bindings/CallSite.cpp +++ b/src/bun.js/bindings/CallSite.cpp @@ -134,7 +134,7 @@ void CallSite::formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WT auto catchScope = DECLARE_CATCH_SCOPE(vm); auto className = object->calculatedClassName(object); if (catchScope.exception()) { - catchScope.clearException(); + (void)catchScope.tryClearException(); } if (className.length() > 0) { diff --git a/src/bun.js/bindings/ErrorCode.cpp b/src/bun.js/bindings/ErrorCode.cpp index 47fc9d00b8..3366f3afc8 100644 --- a/src/bun.js/bindings/ErrorCode.cpp +++ b/src/bun.js/bindings/ErrorCode.cpp @@ -208,7 +208,7 @@ JSObject* ErrorCodeCache::createError(VM& vm, Zig::GlobalObject* globalObject, E auto* structure = jsCast(cache->internalField(static_cast(code)).get()); auto* created_error = JSC::ErrorInstance::create(globalObject, structure, message, options, nullptr, JSC::RuntimeType::TypeNothing, data.type, true); if (auto* thrown_exception = scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); // TODO investigate what can throw here and whether it will throw non-objects // (this is better than before where we would have returned nullptr from createError if any // exception were thrown by ErrorInstance::create) diff --git a/src/bun.js/bindings/ErrorStackTrace.cpp b/src/bun.js/bindings/ErrorStackTrace.cpp index 9117d756bf..7607359268 100644 --- a/src/bun.js/bindings/ErrorStackTrace.cpp +++ b/src/bun.js/bindings/ErrorStackTrace.cpp @@ -645,7 +645,7 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC:: } } if (catchScope.exception()) [[unlikely]] { - catchScope.clearException(); + (void)catchScope.tryClearException(); } } @@ -654,7 +654,7 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC:: auto catchScope = DECLARE_CATCH_SCOPE(vm); functionName = JSC::getCalculatedDisplayName(vm, object); if (catchScope.exception()) [[unlikely]] { - catchScope.clearException(); + (void)catchScope.tryClearException(); } } diff --git a/src/bun.js/bindings/FormatStackTraceForJS.cpp b/src/bun.js/bindings/FormatStackTraceForJS.cpp index bd53f19267..8b61c797b2 100644 --- a/src/bun.js/bindings/FormatStackTraceForJS.cpp +++ b/src/bun.js/bindings/FormatStackTraceForJS.cpp @@ -531,7 +531,7 @@ WTF::String computeErrorInfoWrapperToString(JSC::VM& vm, Vector& sta if (scope.exception()) { // TODO: is this correct? vm.setOnComputeErrorInfo doesnt appear to properly handle a function that can throw // test/js/node/test/parallel/test-stream-writable-write-writev-finish.js is the one that trips the exception checker - scope.clearException(); + (void)scope.tryClearException(); result = WTF::emptyString(); } diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index c1152b494f..5315548f18 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -534,7 +534,7 @@ extern "C" void JSBundlerPlugin__matchOnLoad(Bun::JSBundlerPlugin* plugin, const if (scope.exception()) [[unlikely]] { auto exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); if (!plugin->plugin.tombstoned) { plugin->plugin.addError( context, @@ -577,7 +577,7 @@ extern "C" void JSBundlerPlugin__matchOnResolve(Bun::JSBundlerPlugin* plugin, co if (scope.exception()) [[unlikely]] { auto exception = JSValue(scope.exception()); - scope.clearException(); + (void)scope.tryClearException(); if (!plugin->plugin.tombstoned) { JSBundlerPlugin__addError( context, diff --git a/src/bun.js/bindings/JSCommonJSModule.cpp b/src/bun.js/bindings/JSCommonJSModule.cpp index 095d305e66..e0daa7e004 100644 --- a/src/bun.js/bindings/JSCommonJSModule.cpp +++ b/src/bun.js/bindings/JSCommonJSModule.cpp @@ -230,7 +230,7 @@ bool JSCommonJSModule::load(JSC::VM& vm, Zig::GlobalObject* globalObject) this->m_filename.get()); if (auto exception = scope.exception()) { - scope.clearException(); + (void)scope.tryClearException(); // On error, remove the module from the require map/ // so that it can be re-evaluated on the next require. @@ -1023,7 +1023,7 @@ void populateESMExports( JSC::PropertyNameArrayBuilder properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Exclude); if (scope.exception()) [[unlikely]] { - if (!vm.hasPendingTerminationException()) scope.clearException(); + if (!vm.hasPendingTerminationException()) (void)scope.tryClearException(); return; } @@ -1055,7 +1055,7 @@ void populateESMExports( // If it throws, we keep them in the exports list, but mark it as undefined // This is consistent with what Node.js does. if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); getterResult = jsUndefined(); } @@ -1081,7 +1081,7 @@ void populateESMExports( JSC::PropertyNameArrayBuilder properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Include); if (scope.exception()) [[unlikely]] { - if (!vm.hasPendingTerminationException()) scope.clearException(); + if (!vm.hasPendingTerminationException()) (void)scope.tryClearException(); return; } @@ -1113,7 +1113,7 @@ void populateESMExports( // If it throws, we keep them in the exports list, but mark it as undefined // This is consistent with what Node.js does. if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); getterResult = jsUndefined(); } @@ -1221,7 +1221,7 @@ ALWAYS_INLINE EncodedJSValue finishRequireWithError(Zig::GlobalObject* globalObj { JSC::JSValue exception = throwScope.exception(); ASSERT(exception); - throwScope.clearException(); + (void)throwScope.tryClearException(); // On error, remove the module from the require map/ // so that it can be re-evaluated on the next require. @@ -1504,7 +1504,7 @@ std::optional createCommonJSModule( moduleObject->m_dirname.get(), moduleObject->m_filename.get()); if (auto exception = scope.exception()) { - scope.clearException(); + (void)scope.tryClearException(); // On error, remove the module from the require map // so that it can be re-evaluated on the next require. diff --git a/src/bun.js/bindings/JSDOMExceptionHandling.cpp b/src/bun.js/bindings/JSDOMExceptionHandling.cpp index 2b8bd8a3ab..b0d10ba810 100644 --- a/src/bun.js/bindings/JSDOMExceptionHandling.cpp +++ b/src/bun.js/bindings/JSDOMExceptionHandling.cpp @@ -55,7 +55,7 @@ void reportException(JSGlobalObject* lexicalGlobalObject, JSC::Exception* except ErrorHandlingScope errorScope(lexicalGlobalObject->vm()); // auto callStack = Inspector::createScriptCallStackFromException(lexicalGlobalObject, exception); - scope.clearException(); + (void)scope.tryClearException(); vm.clearLastException(); auto* globalObject = jsCast(lexicalGlobalObject); @@ -112,7 +112,7 @@ String retrieveErrorMessageWithoutName(JSGlobalObject& lexicalGlobalObject, VM& // We need to clear any new exception that may be thrown in the toString() call above. // reportException() is not supposed to be making new exceptions. - catchScope.clearException(); + (void)catchScope.tryClearException(); vm.clearLastException(); return errorMessage; } @@ -129,7 +129,7 @@ String retrieveErrorMessage(JSGlobalObject& lexicalGlobalObject, VM& vm, JSValue // We need to clear any new exception that may be thrown in the toString() call above. // reportException() is not supposed to be making new exceptions. - catchScope.clearException(); + (void)catchScope.tryClearException(); vm.clearLastException(); return errorMessage; } @@ -139,7 +139,7 @@ void reportCurrentException(JSGlobalObject* lexicalGlobalObject) auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_CATCH_SCOPE(vm); auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); reportException(lexicalGlobalObject, exception); } diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index 3e454c6c00..e7e9021cef 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -315,7 +315,7 @@ public: this->setName(nameToUse); if (catcher.exception()) { - catcher.clearException(); + (void)catcher.tryClearException(); } } @@ -939,7 +939,7 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionCall, (JSGlobalObject * lexicalGlobalObje if (auto* returnValuesArray = fn->returnValues.get()) { returnValuesArray->putDirectIndex(globalObject, returnValueIndex, createMockResult(vm, globalObject, "throw"_s, exc->value())); fn->returnValues.set(vm, fn, returnValuesArray); - catchScope.clearException(); + (void)catchScope.tryClearException(); JSC::throwException(globalObject, scope, exc); return {}; } diff --git a/src/bun.js/bindings/JSX509Certificate.cpp b/src/bun.js/bindings/JSX509Certificate.cpp index 0dfee02575..bcc7e0a10e 100644 --- a/src/bun.js/bindings/JSX509Certificate.cpp +++ b/src/bun.js/bindings/JSX509Certificate.cpp @@ -187,7 +187,7 @@ void JSX509Certificate::finishCreation(VM& vm) auto scope = DECLARE_THROW_SCOPE(init.vm); auto value = init.owner->computeSubject(init.owner->view(), init.owner->globalObject(), false); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); return init.set(jsEmptyString(init.vm)); } if (!value.isString()) { @@ -201,7 +201,7 @@ void JSX509Certificate::finishCreation(VM& vm) auto scope = DECLARE_THROW_SCOPE(init.vm); JSValue value = init.owner->computeIssuer(init.owner->view(), init.owner->globalObject(), false); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); return init.set(jsEmptyString(init.vm)); } if (value.isString()) { diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 3099bdcc64..fa63cfebc8 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -138,7 +138,7 @@ static OnLoadResult handleOnLoadObjectResult(Zig::GlobalObject* globalObject, JS auto exportsValue = object->getIfPropertyExists(globalObject, builtinNames.exportsPublicName()); if (scope.exception()) [[unlikely]] { result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } if (exportsValue) { @@ -151,7 +151,7 @@ static OnLoadResult handleOnLoadObjectResult(Zig::GlobalObject* globalObject, JS scope.throwException(globalObject, createTypeError(globalObject, "\"object\" loader must return an \"exports\" object"_s)); result.type = OnLoadResultTypeError; result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } @@ -228,7 +228,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: if (!object) [[unlikely]] { scope.throwException(globalObject, JSC::createError(globalObject, "Expected module mock to return an object"_s)); result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); result.type = OnLoadResultTypeError; return result; } @@ -236,7 +236,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: auto loaderValue = object->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "loader"_s)); if (scope.exception()) [[unlikely]] { result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } if (loaderValue) { @@ -247,7 +247,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: JSC::JSString* loaderJSString = loaderValue.toStringOrNull(globalObject); if (auto ex = scope.exception()) [[unlikely]] { result.value.error = ex; - scope.clearException(); + (void)scope.tryClearException(); return result; } if (loaderJSString) { @@ -276,7 +276,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: if (loader == BunLoaderTypeNone) [[unlikely]] { throwException(globalObject, scope, createError(globalObject, "Expected loader to be one of \"js\", \"jsx\", \"object\", \"ts\", \"tsx\", \"toml\", \"yaml\", or \"json\""_s)); result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } @@ -287,7 +287,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: auto contentsValue = object->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "contents"_s)); if (scope.exception()) [[unlikely]] { result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } if (contentsValue) { @@ -305,7 +305,7 @@ OnLoadResult handleOnLoadResultNotPromise(Zig::GlobalObject* globalObject, JSC:: if (result.value.sourceText.value.isEmpty()) [[unlikely]] { throwException(globalObject, scope, createError(globalObject, "Expected \"contents\" to be a string or an ArrayBufferView"_s)); result.value.error = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return result; } @@ -364,7 +364,7 @@ static JSValue handleVirtualModuleResult( const auto rejectOrResolve = [&](JSValue code) -> JSValue { if (auto* exception = scope.exception()) { if constexpr (allowPromise) { - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, rejectedInternalPromise(globalObject, exception)); } else { return exception; @@ -501,7 +501,7 @@ extern "C" void Bun__onFulfillAsyncModule( } else { auto* exception = scope.exception(); if (!vm.isTerminationException(exception)) { - scope.clearException(); + (void)scope.tryClearException(); promise->reject(vm, globalObject, exception); scope.assertNoExceptionExceptTermination(); } @@ -915,7 +915,7 @@ static JSValue fetchESMSourceCode( return {}; } - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, rejectedInternalPromise(globalObject, exception)); } @@ -944,7 +944,7 @@ static JSValue fetchESMSourceCode( if (!res->success) { throwException(scope, res->result.err, globalObject); auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, reject(exception)); } @@ -958,7 +958,7 @@ static JSValue fetchESMSourceCode( if constexpr (allowPromise) { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, rejectedInternalPromise(globalObject, exception)); } else { scope.release(); @@ -1024,7 +1024,7 @@ static JSValue fetchESMSourceCode( if constexpr (allowPromise) { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, rejectedInternalPromise(globalObject, exception)); } else { scope.release(); @@ -1035,7 +1035,7 @@ static JSValue fetchESMSourceCode( if (!res->success) { throwException(scope, res->result.err, globalObject); auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, reject(exception)); } @@ -1055,7 +1055,7 @@ static JSValue fetchESMSourceCode( JSC::JSValue value = JSC::JSONParseWithException(globalObject, jsonSource); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, reject(exception)); } diff --git a/src/bun.js/bindings/NodeTimerObject.cpp b/src/bun.js/bindings/NodeTimerObject.cpp index 93dbc0ae2c..f6239ead09 100644 --- a/src/bun.js/bindings/NodeTimerObject.cpp +++ b/src/bun.js/bindings/NodeTimerObject.cpp @@ -61,7 +61,7 @@ static bool call(JSGlobalObject* globalObject, JSValue timerObject, JSValue call if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); Bun__reportUnhandledError(globalObject, JSValue::encode(exception)); hadException = true; } diff --git a/src/bun.js/bindings/NodeVM.cpp b/src/bun.js/bindings/NodeVM.cpp index c8e1053672..b91a8b829d 100644 --- a/src/bun.js/bindings/NodeVM.cpp +++ b/src/bun.js/bindings/NodeVM.cpp @@ -945,10 +945,12 @@ bool NodeVMGlobalObject::getOwnPropertySlot(JSObject* cell, JSGlobalObject* glob if (slot.internalMethodType() == JSC::PropertySlot::InternalMethodType::Get && contextifiedObject->type() == JSC::ProxyObjectType) { JSC::ProxyObject* proxyObject = jsCast(contextifiedObject); - JSValue handlerValue = proxyObject->handler(); - if (handlerValue.isNull()) + if (proxyObject->isRevoked()) return throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); + JSValue handlerValue = proxyObject->handler(); + if (!handlerValue.isObject()) + return throwTypeError(globalObject, scope, s_proxyAlreadyRevokedErrorMessage); JSObject* handler = jsCast(handlerValue); CallData callData; JSObject* getHandler = proxyObject->getHandlerTrap(globalObject, handler, callData, vm.propertyNames->get, ProxyObject::HandlerTrap::Get); diff --git a/src/bun.js/bindings/NodeVMModule.cpp b/src/bun.js/bindings/NodeVMModule.cpp index 202692f1f5..c0bdd9dc66 100644 --- a/src/bun.js/bindings/NodeVMModule.cpp +++ b/src/bun.js/bindings/NodeVMModule.cpp @@ -128,7 +128,7 @@ JSValue NodeVMModule::evaluate(JSGlobalObject* globalObject, uint32_t timeout, b if (vm.hasPendingTerminationException()) { vm.drainMicrotasksForGlobalObject(nodeVmGlobalObject); - scope.clearException(); + DECLARE_CATCH_SCOPE(vm).clearException(); vm.clearHasTerminationRequest(); if (getSigintReceived()) { setSigintReceived(false); diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 40e401977d..b228ec5c5e 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2829,7 +2829,7 @@ uint8_t GlobalObject::drainMicrotasks() } #if ASSERT_ENABLED - scope.clearException(); + (void)scope.tryClearException(); // We should not have an exception here. // But it's an easy mistake to make. // Let's log it so that we can debug this. @@ -2850,7 +2850,7 @@ uint8_t GlobalObject::drainMicrotasks() if (vm.isTerminationException(exception)) { return 1; } - scope.clearException(); + (void)scope.tryClearException(); this->reportUncaughtExceptionAtEventLoop(this, exception); return 0; } @@ -2860,7 +2860,7 @@ uint8_t GlobalObject::drainMicrotasks() if (vm.isTerminationException(exception)) { return 1; } - scope.clearException(); + (void)scope.tryClearException(); this->reportUncaughtExceptionAtEventLoop(this, exception); } @@ -2957,7 +2957,7 @@ extern "C" void JSGlobalObject__clearTerminationException(JSC::JSGlobalObject* g // In case it actually has been thrown, clear the exception itself as well auto scope = DECLARE_CATCH_SCOPE(vm); if (scope.exception() && vm.isTerminationException(scope.exception())) { - scope.clearException(); + (void)scope.tryClearException(); } } @@ -3002,7 +3002,7 @@ void GlobalObject::handleRejectedPromises() Bun__handleRejectedPromise(this, promise); if (auto ex = scope.exception()) { - scope.clearException(); + (void)scope.tryClearException(); this->reportUncaughtExceptionAtEventLoop(this, ex); } } diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 919505c7c2..1572ce13a1 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3363,7 +3363,7 @@ void JSC__AnyPromise__wrap(JSC::JSGlobalObject* globalObject, EncodedJSValue enc JSValue result = JSC::JSValue::decode(func(ctx, globalObject)); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); if (auto* promise = jsDynamicCast(promiseValue)) { promise->reject(vm, globalObject, exception->value()); @@ -3418,7 +3418,7 @@ JSC::EncodedJSValue JSC__JSPromise__wrap(JSC::JSGlobalObject* globalObject, void JSValue result = JSC::JSValue::decode(func(ctx, globalObject)); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSPromise::rejectedPromise(globalObject, exception->value()))); } @@ -3433,7 +3433,7 @@ JSC::EncodedJSValue JSC__JSPromise__wrap(JSC::JSGlobalObject* globalObject, void JSValue resolved = JSC::JSPromise::resolvedPromise(globalObject, result); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSPromise::rejectedPromise(globalObject, exception->value()))); } @@ -5042,7 +5042,7 @@ restart: if (objectToUse == object) { propertyValue = objectToUse->getDirect(entry.offset()); if (!propertyValue) { - scope.clearException(); + (void)scope.tryClearException(); return true; } } @@ -5174,7 +5174,7 @@ restart: // Ignore exceptions from getters. if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); propertyValue = jsUndefined(); } @@ -5207,7 +5207,7 @@ restart: properties.releaseData(); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); return; } } @@ -5268,7 +5268,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] bool JSC__isBigIntInInt64Range(JSC::EncodedJS JSC::JSObject::getOwnPropertyNames(object, globalObject, properties, DontEnumPropertiesMode::Include); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); return; } } @@ -5291,7 +5291,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] bool JSC__isBigIntInInt64Range(JSC::EncodedJS JSC::PropertySlot slot(object, PropertySlot::InternalMethodType::Get); bool hasProperty = object->getPropertySlot(globalObject, property, slot); - scope.clearException(); + (void)scope.tryClearException(); if (!hasProperty) { continue; } @@ -5322,7 +5322,7 @@ extern "C" [[ZIG_EXPORT(nothrow)]] bool JSC__isBigIntInInt64Range(JSC::EncodedJS } if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); propertyValue = jsUndefined(); } @@ -5870,7 +5870,7 @@ extern "C" bool JSGlobalObject__hasException(JSC::JSGlobalObject* globalObject) extern "C" void JSGlobalObject__clearException(JSC::JSGlobalObject* globalObject) { - DECLARE_CATCH_SCOPE(globalObject->vm()).clearException(); + (void)DECLARE_CATCH_SCOPE(globalObject->vm()).tryClearException(); } extern "C" bool JSGlobalObject__clearExceptionExceptTermination(JSC::JSGlobalObject* globalObject) @@ -5883,7 +5883,7 @@ extern "C" JSC::EncodedJSValue JSGlobalObject__tryTakeException(JSC::JSGlobalObj auto scope = DECLARE_CATCH_SCOPE(globalObject->vm()); if (auto exception = scope.exception()) { - scope.clearException(); + (void)scope.tryClearException(); return JSC::JSValue::encode(exception); } diff --git a/src/bun.js/bindings/headers-handwritten.h b/src/bun.js/bindings/headers-handwritten.h index 956085e43e..546d804181 100644 --- a/src/bun.js/bindings/headers-handwritten.h +++ b/src/bun.js/bindings/headers-handwritten.h @@ -477,7 +477,7 @@ ALWAYS_INLINE void BunString::deref() } } -#define CLEAR_IF_EXCEPTION(scope__) scope__.clearException(); +#define CLEAR_IF_EXCEPTION(scope__) (void)scope__.tryClearException(); #endif // __cplusplus #endif // HEADERS_HANDWRITTEN diff --git a/src/bun.js/bindings/helpers.h b/src/bun.js/bindings/helpers.h index 16411881e0..f54112cf67 100644 --- a/src/bun.js/bindings/helpers.h +++ b/src/bun.js/bindings/helpers.h @@ -344,14 +344,14 @@ static ZigString toZigString(JSC::JSValue val, JSC::JSGlobalObject* global) auto* str = val.toString(global); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); scope.release(); return ZigStringEmpty; } auto view = str->view(global); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); scope.release(); return ZigStringEmpty; } diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index 447287be0e..884f3c4535 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -1336,7 +1336,7 @@ extern "C" napi_status napi_get_and_clear_last_exception(napi_env env, } else { *result = toNapi(JSC::jsUndefined(), globalObject); } - scope.clearException(); + (void)scope.tryClearException(); return napi_set_last_error(env, napi_ok); } diff --git a/src/bun.js/bindings/node/NodeTimers.cpp b/src/bun.js/bindings/node/NodeTimers.cpp index dd3472d7d9..ae97ecdc2b 100644 --- a/src/bun.js/bindings/node/NodeTimers.cpp +++ b/src/bun.js/bindings/node/NodeTimers.cpp @@ -52,7 +52,8 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeout, /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName; @@ -108,7 +109,8 @@ JSC_DEFINE_HOST_FUNCTION(functionSetInterval, /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName; @@ -175,7 +177,8 @@ JSC_DEFINE_HOST_FUNCTION(functionClearImmediate, /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName; @@ -196,7 +199,8 @@ JSC_DEFINE_HOST_FUNCTION(functionClearInterval, /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName; @@ -217,7 +221,8 @@ JSC_DEFINE_HOST_FUNCTION(functionClearTimeout, /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName; diff --git a/src/bun.js/bindings/node/crypto/CryptoGenKeyPair.cpp b/src/bun.js/bindings/node/crypto/CryptoGenKeyPair.cpp index a551f1fbba..77c155fbfd 100644 --- a/src/bun.js/bindings/node/crypto/CryptoGenKeyPair.cpp +++ b/src/bun.js/bindings/node/crypto/CryptoGenKeyPair.cpp @@ -47,7 +47,7 @@ void KeyPairJobCtx::runFromJS(JSGlobalObject* lexicalGlobalObject, JSValue callb JSValue publicKeyValue = m_keyObj.exportPublic(lexicalGlobalObject, scope, m_publicKeyEncoding); if (scope.exception()) [[unlikely]] { JSValue exceptionValue = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); exceptionCallback(exceptionValue); return; } @@ -55,7 +55,7 @@ void KeyPairJobCtx::runFromJS(JSGlobalObject* lexicalGlobalObject, JSValue callb JSValue privateKeyValue = m_keyObj.exportPrivate(lexicalGlobalObject, scope, m_privateKeyEncoding); if (scope.exception()) [[unlikely]] { JSValue exceptionValue = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); exceptionCallback(exceptionValue); return; } diff --git a/src/bun.js/bindings/node/crypto/CryptoPrimes.cpp b/src/bun.js/bindings/node/crypto/CryptoPrimes.cpp index a900b56f1e..aa281f6447 100644 --- a/src/bun.js/bindings/node/crypto/CryptoPrimes.cpp +++ b/src/bun.js/bindings/node/crypto/CryptoPrimes.cpp @@ -209,7 +209,7 @@ void GeneratePrimeJobCtx::runFromJS(JSGlobalObject* globalObject, JSValue callba EXCEPTION_ASSERT(result.isEmpty() == !!scope.exception()); if (scope.exception()) [[unlikely]] { auto* err = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); Bun__EventLoop__runCallback1( globalObject, JSValue::encode(callback), diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 1e25404657..ac9948c7d8 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -1127,8 +1127,11 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSetCustomSQLite, (JSC::JSGlobalObject * l return {}; } - sqlite3_lib_path = sqliteStrValue.toWTFString(lexicalGlobalObject).utf8().data(); + // Use a static CString to keep the string alive for the lifetime of the process + static CString sqlite3_lib_path_storage; + sqlite3_lib_path_storage = sqliteStrValue.toWTFString(lexicalGlobalObject).utf8(); RETURN_IF_EXCEPTION(scope, {}); + sqlite3_lib_path = sqlite3_lib_path_storage.data(); if (lazyLoadSQLite() == -1) { sqlite3_handle = nullptr; @@ -1322,9 +1325,11 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje auto entryPointStr = callFrame->argumentCount() > 2 && callFrame->argument(2).isString() ? callFrame->argument(2).toWTFString(lexicalGlobalObject) : String(); RETURN_IF_EXCEPTION(scope, {}); - const char* entryPoint = entryPointStr.length() == 0 ? NULL : entryPointStr.utf8().data(); + auto entryPointUtf8 = entryPointStr.utf8(); + const char* entryPoint = entryPointStr.length() == 0 ? NULL : entryPointUtf8.data(); + auto extensionStringUtf8 = extensionString.utf8(); char* error; - int rc = sqlite3_load_extension(db, extensionString.utf8().data(), entryPoint, &error); + int rc = sqlite3_load_extension(db, extensionStringUtf8.data(), entryPoint, &error); // TODO: can we disable loading extensions after this? if (rc != SQLITE_OK) { @@ -1657,7 +1662,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje auto catchScope = DECLARE_CATCH_SCOPE(vm); String path = pathValue.toWTFString(lexicalGlobalObject); RETURN_IF_EXCEPTION(catchScope, JSValue::encode(jsUndefined())); - catchScope.clearException(); + (void)catchScope.tryClearException(); int openFlags = DEFAULT_SQLITE_FLAGS; if (callFrame->argumentCount() > 1) { JSValue flags = callFrame->argument(1); diff --git a/src/bun.js/bindings/webcore/JSCallbackData.cpp b/src/bun.js/bindings/webcore/JSCallbackData.cpp index 32567a04c0..c97b045371 100644 --- a/src/bun.js/bindings/webcore/JSCallbackData.cpp +++ b/src/bun.js/bindings/webcore/JSCallbackData.cpp @@ -67,7 +67,7 @@ JSValue JSCallbackData::invokeCallback(VM& vm, JSObject* callback, JSValue thisV function = callback->get(lexicalGlobalObject, functionName); if (scope.exception()) [[unlikely]] { returnedException = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); return JSValue(); } diff --git a/src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp b/src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp index e26b6bb831..aec764b49e 100644 --- a/src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp +++ b/src/bun.js/bindings/webcore/JSDOMPromiseDeferred.cpp @@ -158,7 +158,7 @@ void DeferredPromise::reject(Exception exception, RejectAsHandled rejectAsHandle EXCEPTION_ASSERT(scope.exception()); auto error = scope.exception()->value(); bool isTerminating = handleTerminationExceptionIfNeeded(scope, lexicalGlobalObject); - scope.clearException(); + (void)scope.tryClearException(); if (!isTerminating) reject(error, rejectAsHandled); @@ -193,7 +193,7 @@ void DeferredPromise::reject(ExceptionCode ec, const String& message, RejectAsHa EXCEPTION_ASSERT(scope.exception()); auto error = scope.exception()->value(); bool isTerminating = handleTerminationExceptionIfNeeded(scope, lexicalGlobalObject); - scope.clearException(); + (void)scope.tryClearException(); if (!isTerminating) reject(error, rejectAsHandled); @@ -230,7 +230,7 @@ void rejectPromiseWithExceptionIfAny(JSC::JSGlobalObject& lexicalGlobalObject, J return; JSValue error = catchScope.exception()->value(); - catchScope.clearException(); + (void)catchScope.tryClearException(); DeferredPromise::create(globalObject, promise)->reject(error); } diff --git a/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp b/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp index 924ee30bb5..41a6b956a0 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitterCustom.cpp @@ -77,7 +77,7 @@ JSEventEmitter* jsEventEmitterCastFast(VM& vm, JSC::JSGlobalObject* lexicalGloba thisObject->putDirect(vm, name, result, 0); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); return nullptr; } diff --git a/src/bun.js/bindings/webcore/JSEventListener.cpp b/src/bun.js/bindings/webcore/JSEventListener.cpp index fe36e1dfef..b4f61be1c5 100644 --- a/src/bun.js/bindings/webcore/JSEventListener.cpp +++ b/src/bun.js/bindings/webcore/JSEventListener.cpp @@ -205,7 +205,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext& scriptExecutionContext handleEventFunction = jsFunction->get(lexicalGlobalObject, Identifier::fromString(vm, "handleEvent"_s)); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); event.target()->uncaughtExceptionInEventHandler(); reportException(lexicalGlobalObject, exception); return; @@ -257,7 +257,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext& scriptExecutionContext auto then = retval.get(lexicalGlobalObject, vm.propertyNames->then); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); event.target()->uncaughtExceptionInEventHandler(); reportException(lexicalGlobalObject, exception); return; @@ -269,7 +269,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext& scriptExecutionContext JSC::call(lexicalGlobalObject, then, retval, arglist, "Promise.then is not callable"_s); if (scope.exception()) [[unlikely]] { auto* exception = scope.exception(); - scope.clearException(); + (void)scope.tryClearException(); event.target()->uncaughtExceptionInEventHandler(); reportException(lexicalGlobalObject, exception); return; diff --git a/src/bun.js/bindings/webcore/JSEventTarget.cpp b/src/bun.js/bindings/webcore/JSEventTarget.cpp index f2b75d165b..76a2ca951f 100644 --- a/src/bun.js/bindings/webcore/JSEventTarget.cpp +++ b/src/bun.js/bindings/webcore/JSEventTarget.cpp @@ -241,7 +241,7 @@ static inline JSC::EncodedJSValue jsEventTargetPrototypeFunction_addEventListene errorInstance->putDirect(vm, vm.propertyNames->type, jsString(vm, WTF::move(type))); Bun::Process::emitWarningErrorInstance(lexicalGlobalObject, errorInstance); if (throwScope.exception()) [[unlikely]] - throwScope.clearException(); + (void)throwScope.tryClearException(); } auto result = JSValue::encode(toJS(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.addEventListenerForBindings(WTF::move(type), WTF::move(listener), WTF::move(options)); })); RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp index 0240fbc8c0..56b2b2b7f6 100644 --- a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp +++ b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp @@ -6154,7 +6154,7 @@ RefPtr SerializedScriptValue::create(JSContextRef originC if (scope.exception()) [[unlikely]] { if (exception) *exception = toRef(lexicalGlobalObject, scope.exception()->value()); - scope.clearException(); + (void)scope.tryClearException(); return nullptr; } ASSERT(serializedValue); @@ -6385,7 +6385,7 @@ JSValueRef SerializedScriptValue::deserialize(JSContextRef destinationContext, J if (scope.exception()) [[unlikely]] { if (exception) *exception = toRef(lexicalGlobalObject, scope.exception()->value()); - scope.clearException(); + (void)scope.tryClearException(); return nullptr; } ASSERT(value); diff --git a/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp b/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp index 3ebd67bad8..84a506191b 100644 --- a/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp +++ b/src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp @@ -379,7 +379,7 @@ static inline JSC::EncodedJSValue jsSubtleCryptoPrototypeFunction_digestBody(JSC EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1); auto data = convert>(*lexicalGlobalObject, argument1.value()); if (throwScope.exception()) [[unlikely]] { - throwScope.clearException(); + (void)throwScope.tryClearException(); return Bun::ERR::INVALID_ARG_TYPE(throwScope, lexicalGlobalObject, "data"_s, "ArrayBuffer, Buffer, TypedArray, or DataView"_s, argument1.value()); } RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.digest(*jsCast(lexicalGlobalObject), WTF::move(algorithm), WTF::move(data), WTF::move(promise)); }))); diff --git a/src/bun.js/modules/BunTestModule.h b/src/bun.js/modules/BunTestModule.h index 410e597ad2..5132416d88 100644 --- a/src/bun.js/modules/BunTestModule.h +++ b/src/bun.js/modules/BunTestModule.h @@ -20,7 +20,7 @@ void generateNativeModule_BunTest( JSC::PropertyNameArrayBuilder properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude); object->methodTable()->getOwnPropertyNames(object, lexicalGlobalObject, properties, JSC::DontEnumPropertiesMode::Exclude); if (catchScope.exception()) [[unlikely]] { - catchScope.clearException(); + (void)catchScope.tryClearException(); return; } @@ -28,7 +28,7 @@ void generateNativeModule_BunTest( JSC::PropertySlot slot(object, JSC::PropertySlot::InternalMethodType::Get); auto ownPropertySlot = object->methodTable()->getOwnPropertySlot(object, lexicalGlobalObject, property, slot); if (catchScope.exception()) [[unlikely]] { - catchScope.clearException(); + (void)catchScope.tryClearException(); } if (ownPropertySlot) { exportNames.append(property); diff --git a/src/bun.js/modules/NodeModuleModule.cpp b/src/bun.js/modules/NodeModuleModule.cpp index ac72ec7970..bd9c52c148 100644 --- a/src/bun.js/modules/NodeModuleModule.cpp +++ b/src/bun.js/modules/NodeModuleModule.cpp @@ -1155,7 +1155,7 @@ void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, if (constructor->hasNonReifiedStaticProperties()) { constructor->reifyAllStaticProperties(globalObject); if (catchScope.exception()) { - catchScope.clearException(); + (void)catchScope.tryClearException(); } } @@ -1172,7 +1172,7 @@ void generateNativeModule_NodeModule(JSC::JSGlobalObject* lexicalGlobalObject, if (catchScope.exception()) [[unlikely]] { value = {}; - catchScope.clearException(); + (void)catchScope.tryClearException(); } exportNames.append(property); diff --git a/src/bun.js/modules/NodeProcessModule.h b/src/bun.js/modules/NodeProcessModule.h index 071998af57..8ad1750d86 100644 --- a/src/bun.js/modules/NodeProcessModule.h +++ b/src/bun.js/modules/NodeProcessModule.h @@ -37,7 +37,7 @@ DEFINE_NATIVE_MODULE(NodeProcess) JSValue result = process->get(globalObject, entry); if (catchScope.exception()) { result = jsUndefined(); - catchScope.clearException(); + (void)catchScope.tryClearException(); } exportValues.append(result); diff --git a/src/bun.js/modules/ObjectModule.cpp b/src/bun.js/modules/ObjectModule.cpp index d5accd979b..3f243e5a0c 100644 --- a/src/bun.js/modules/ObjectModule.cpp +++ b/src/bun.js/modules/ObjectModule.cpp @@ -27,7 +27,7 @@ generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject, auto scope = DECLARE_CATCH_SCOPE(vm); JSValue value = object->get(globalObject, entry); if (scope.exception()) [[unlikely]] { - scope.clearException(); + (void)scope.tryClearException(); value = jsUndefined(); } exportValues.append(value); diff --git a/src/codegen/generate-classes.ts b/src/codegen/generate-classes.ts index 929585c976..1edfb6d7ba 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -1296,7 +1296,8 @@ JSC_DEFINE_HOST_FUNCTION(${symbolName(typeName, name)}Callback, (JSGlobalObject /** View the file name of the JS file that called this function * from a debugger */ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); - const char* fileName = sourceOrigin.string().utf8().data(); + auto fileNameUTF8 = sourceOrigin.string().utf8(); + const char* fileName = fileNameUTF8.data(); static const char* lastFileName = nullptr; if (lastFileName != fileName) { lastFileName = fileName;