锁定移动壳未知异常响应
移动端 HostBridge 未知异常统一返回稳定 host_error 文案 移动壳协议测试覆盖普通 Error 不透出原生消息 移动壳配置检查反查未知异常不可透出 Error.message
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user