Skip to content

Commit 23be44b

Browse files
committed
Use throwRecoverableException instead of raw throw for stored exceptions
Replace `throw kj::mv(*exception)` with `kj::throwRecoverableException(kj::mv(*exception))` in the async worker thread exception handler. A raw throw creates a kj::Exception with the calling binary's typeinfo. On macOS with -fvisibility=hidden, this typeinfo is not coalesced with libkj.dylib's copy by the dynamic linker, so getCaughtExceptionAsKj()'s catch (kj::Exception& e) fails and falls through to catch (...), producing "unknown non-KJ exception of type: kj::Exception" errors. throwRecoverableException() routes the throw through libkj, wrapping it in ExceptionImpl with consistent typeinfo. This matches the pattern KJ uses internally in kj/async-inl.h when re-throwing stored exceptions from promises.
1 parent 75c2a27 commit 23be44b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/mp/type-context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
189189
}
190190
})) {
191191
MP_LOG(loop, Log::Error) << "IPC server request #" << req << " uncaught exception (" << kj::str(*exception).cStr() << ")";
192-
throw kj::mv(*exception);
192+
kj::throwRecoverableException(kj::mv(*exception));
193193
}
194194
return call_context;
195195
// End of scope: if KJ_DEFER was reached, it runs here

0 commit comments

Comments
 (0)