mirror of
https://ghproxy.cflmy.top/https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-12-01 01:29:35 +08:00
fix(im): attach rejection handler before readWithin early abort
This commit is contained in:
1 parent
13222bc40e
commit
bca637496d
2 files changed
+8
No files matched your search
@@ -555,6 +555,9 @@ export class ImIntake {
|
||||
* @returns what the platform answered.
|
||||
*/
|
||||
export async function readWithin<T>(read: Promise<T>, timeout: number, signal?: AbortSignal): Promise<T> {
|
||||
// Attach a no-op handler immediately so a rejected platform request cannot trigger `unhandledRejection` if
|
||||
// `signal?.aborted` throws early or the deadline/abort wins the race.
|
||||
void read.catch(() => {})
|
||||
if (signal?.aborted) {
|
||||
throw new ImError('unavailable', 'the platform read was aborted', { cause: signal.reason })
|
||||
}
|
||||
|
||||
@@ -262,6 +262,11 @@ describe('ImService facade', () => {
|
||||
const pendingRead = service.readMessage(CHAT, 'm-abort', controller.signal)
|
||||
controller.abort(new Error('cancelled'))
|
||||
await expect(pendingRead).rejects.toMatchObject({ code: 'unavailable' })
|
||||
|
||||
const preAborted = new AbortController()
|
||||
preAborted.abort(new Error('already cancelled'))
|
||||
bot.getMessage = () => Promise.reject(new Error('late platform failure'))
|
||||
await expect(service.readMessage(CHAT, 'm-pre-aborted', preAborted.signal)).rejects.toMatchObject({ code: 'unavailable' })
|
||||
})
|
||||
|
||||
it('publishes and streams through the send funnel of its sender', async () => {
|
||||
|
||||
Reference in new issue
Block a user