Skip to content

Commit

Permalink
fix(vitest): ignore timeout on websocket reporter rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Mar 14, 2024
1 parent e77c553 commit 38119b7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/vitest/src/api/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { StackTraceParserOptions } from '@vitest/utils/source-map'
import { API_PATH } from '../constants'
import type { Vitest } from '../node'
import type { File, ModuleGraphData, Reporter, TaskResultPack, UserConsoleLog } from '../types'
import { getModuleGraph, isPrimitive, stringifyReplace } from '../utils'
import { getModuleGraph, isPrimitive, noop, stringifyReplace } from '../utils'
import type { WorkspaceProject } from '../node/workspace'
import { parseErrorStacktrace } from '../utils/source-map'
import type { TransformResultWithSource, WebSocketEvents, WebSocketHandlers } from './types'
Expand Down Expand Up @@ -168,7 +168,7 @@ export function setup(vitestOrWorkspace: Vitest | WorkspaceProject, _server?: Vi
{
post: msg => ws.send(msg),
on: fn => ws.on('message', fn),
eventNames: ['onUserConsoleLog', 'onFinished', 'onFinishedReportCoverage', 'onCollected', 'onCancel'],
eventNames: ['onUserConsoleLog', 'onFinished', 'onFinishedReportCoverage', 'onCollected', 'onCancel', 'onTaskUpdate'],
serialize: (data: any) => stringify(data, stringifyReplace),
deserialize: parse,
onTimeoutError(functionName) {
Expand Down Expand Up @@ -200,7 +200,7 @@ export class WebSocketReporter implements Reporter {
if (this.clients.size === 0)
return
this.clients.forEach((client) => {
client.onCollected?.(files)
client.onCollected?.(files).catch(noop)
})
}

Expand All @@ -222,25 +222,25 @@ export class WebSocketReporter implements Reporter {
})

this.clients.forEach((client) => {
client.onTaskUpdate?.(packs)
client.onTaskUpdate?.(packs).catch(noop)
})
}

onFinished(files?: File[], errors?: unknown[]) {
this.clients.forEach((client) => {
client.onFinished?.(files, errors)
client.onFinished?.(files, errors).catch(noop)
})
}

onFinishedReportCoverage() {
this.clients.forEach((client) => {
client.onFinishedReportCoverage?.()
client.onFinishedReportCoverage?.().catch(noop)
})
}

onUserConsoleLog(log: UserConsoleLog) {
this.clients.forEach((client) => {
client.onUserConsoleLog?.(log)
client.onUserConsoleLog?.(log).catch(noop)
})
}
}

0 comments on commit 38119b7

Please sign in to comment.