diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index 7a4d49b0b..1210a3472 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -914,6 +914,13 @@ for (const expectedErrorCode of [ ); } } +if ( + protocolSource.includes('error instanceof Error') || + protocolSource.includes('? error.message') || + protocolSource.includes('error.message\n :') +) { + throw new Error('mobile shell protocol must not expose unknown native Error.message values to H5'); +} for (const snippet of [ 'parseRequest', 'isHostBridgeRequest', diff --git a/apps/mobile-shell/src/host-bridge/protocol.test.ts b/apps/mobile-shell/src/host-bridge/protocol.test.ts index c2cd0df97..68feed41c 100644 --- a/apps/mobile-shell/src/host-bridge/protocol.test.ts +++ b/apps/mobile-shell/src/host-bridge/protocol.test.ts @@ -106,7 +106,7 @@ describe('mobile HostBridge protocol helpers', () => { }); expect(normalizeMobileHostBridgeError(new Error('disk failed'))).toEqual({ code: 'host_error', - message: 'disk failed', + message: 'mobile host bridge request failed', }); expect(normalizeMobileHostBridgeError('boom')).toEqual({ code: 'host_error', diff --git a/apps/mobile-shell/src/host-bridge/protocol.ts b/apps/mobile-shell/src/host-bridge/protocol.ts index 0fb2938e7..d5b8b2a58 100644 --- a/apps/mobile-shell/src/host-bridge/protocol.ts +++ b/apps/mobile-shell/src/host-bridge/protocol.ts @@ -107,9 +107,6 @@ export function normalizeMobileHostBridgeError(error: unknown): HostBridgeError return { code: 'host_error', - message: - error instanceof Error - ? error.message - : 'mobile host bridge request failed', + message: 'mobile host bridge request failed', }; }