fix(electron): retain wrapped protocol handler registrations

This commit is contained in:
ShuaixinHuang authored and morluto committed 2026-11-03 23:11:45 +08:00
1 parent 8c857ce56c
commit c28d47bf13
4 files changed
+180 -4

No files matched your search

@@ -87,7 +87,12 @@ export const inspectElectronProtocolNode = (
: INTERCEPTORS.has(target.api)
? "interceptor"
: undefined;
if (role !== undefined && !handlerKnownMissing(node))
// handle installs its own native callback and invokes the supplied handler
// only when a request arrives; a missing handler does not prevent registration.
if (
role !== undefined &&
(target.api === "handle" || !handlerKnownMissing(node))
)
addProtocol(context, {
node,
api: target.api,
@@ -97,7 +102,7 @@ export const inspectElectronProtocolNode = (
});
};
/** Electron requires the callback, so a call without one installs nothing. */
/** Legacy native registration APIs require a callback before installing it. */
const handlerKnownMissing = (
node: t.CallExpression | t.OptionalCallExpression,
): boolean => {