@@ -1390,12 +1390,40 @@ extern "C" void Bun__Process__emitWarning(Zig::GlobalObject* globalObject, Encod
13901390 JSValue::decode (ctor));
13911391}
13921392
1393- JSValue Process::emitWarning (JSC::JSGlobalObject* lexicalGlobalObject, JSValue warning, JSValue type, JSValue code, JSValue ctor )
1393+ JSValue Process::emitWarningErrorInstance (JSC::JSGlobalObject* lexicalGlobalObject, JSValue errorInstance )
13941394{
13951395 Zig::GlobalObject* globalObject = defaultGlobalObject (lexicalGlobalObject);
13961396 VM& vm = getVM (globalObject);
13971397 auto scope = DECLARE_THROW_SCOPE (vm);
13981398 auto * process = jsCast<Process*>(globalObject->processObject ());
1399+
1400+ auto warningName = errorInstance.get (lexicalGlobalObject, vm.propertyNames ->name );
1401+ RETURN_IF_EXCEPTION (scope, {});
1402+ if (isJSValueEqualToASCIILiteral (globalObject, warningName, " DeprecationWarning" _s)) {
1403+ if (Bun__Node__ProcessNoDeprecation) {
1404+ return jsUndefined ();
1405+ }
1406+ if (Bun__Node__ProcessThrowDeprecation) {
1407+ // // Delay throwing the error to guarantee that all former warnings were properly logged.
1408+ // return process.nextTick(() => {
1409+ // throw warning;
1410+ // });
1411+ auto func = JSFunction::create (vm, globalObject, 1 , " " _s, jsFunction_throwValue, JSC::ImplementationVisibility::Private);
1412+ process->queueNextTick (globalObject, func, errorInstance);
1413+ return jsUndefined ();
1414+ }
1415+ }
1416+
1417+ // process.nextTick(doEmitWarning, warning);
1418+ auto func = JSFunction::create (vm, globalObject, 1 , " " _s, jsFunction_emitWarning, JSC::ImplementationVisibility::Private);
1419+ process->queueNextTick (globalObject, func, errorInstance);
1420+ return jsUndefined ();
1421+ }
1422+ JSValue Process::emitWarning (JSC::JSGlobalObject* lexicalGlobalObject, JSValue warning, JSValue type, JSValue code, JSValue ctor)
1423+ {
1424+ Zig::GlobalObject* globalObject = defaultGlobalObject (lexicalGlobalObject);
1425+ VM& vm = getVM (globalObject);
1426+ auto scope = DECLARE_THROW_SCOPE (vm);
13991427 JSValue detail = jsUndefined ();
14001428
14011429 if (Bun__Node__ProcessNoDeprecation && isJSValueEqualToASCIILiteral (globalObject, type, " DeprecationWarning" _s)) {
@@ -1453,25 +1481,7 @@ JSValue Process::emitWarning(JSC::JSGlobalObject* lexicalGlobalObject, JSValue w
14531481 if (!detail.isUndefined ()) errorInstance->putDirect (vm, vm.propertyNames ->detail , detail, JSC::PropertyAttribute::DontEnum | 0 );
14541482 // ErrorCaptureStackTrace(warning, ctor || process.emitWarning);
14551483
1456- if (isJSValueEqualToASCIILiteral (globalObject, type, " DeprecationWarning" _s)) {
1457- if (Bun__Node__ProcessNoDeprecation) {
1458- return jsUndefined ();
1459- }
1460- if (Bun__Node__ProcessThrowDeprecation) {
1461- // // Delay throwing the error to guarantee that all former warnings were properly logged.
1462- // return process.nextTick(() => {
1463- // throw warning;
1464- // });
1465- auto func = JSFunction::create (vm, globalObject, 1 , " " _s, jsFunction_throwValue, JSC::ImplementationVisibility::Private);
1466- process->queueNextTick (globalObject, func, errorInstance);
1467- return jsUndefined ();
1468- }
1469- }
1470-
1471- // process.nextTick(doEmitWarning, warning);
1472- auto func = JSFunction::create (vm, globalObject, 1 , " " _s, jsFunction_emitWarning, JSC::ImplementationVisibility::Private);
1473- process->queueNextTick (globalObject, func, errorInstance);
1474- return jsUndefined ();
1484+ RELEASE_AND_RETURN (scope, emitWarningErrorInstance (lexicalGlobalObject, errorInstance));
14751485}
14761486
14771487JSC_DEFINE_HOST_FUNCTION (Process_emitWarning, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
0 commit comments