Skip to content

Commit

Permalink
remove completion timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Mar 6, 2024
1 parent ca434ed commit 901d83e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const ALL_BRACKETS = [...OPENING_BRACKETS, ...CLOSING_BRACKETS] as const
export const BRACKET_REGEX = /^[()[\]{}]+$/
export const NORMALIZE_REGEX = /\s*\r?\n|\r/g;
export const LINE_BREAK_REGEX = /\r?\n|\r|\n/g
export const COMPLETION_TIMEOUT = 20000 // 20 seconds
export const MAX_CONTEXT_LINE_COUNT = 200
export const SKIP_DECLARATION_SYMBOLS = ['=', ':']
export const IMPORT_SEPARATOR = [',', '{']
Expand Down
15 changes: 2 additions & 13 deletions src/extension/stream.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import { StreamRequest } from '../common/types'
import { logStreamOptions, safeParseJsonResponse } from './utils'
import { COMPLETION_TIMEOUT } from '../common/constants'

export async function streamResponse(request: StreamRequest) {
logStreamOptions(request)
const { body, options, onData, onEnd, onError, onStart } = request
const controller = new AbortController()

const { signal } = controller

const timeoutId = setTimeout(() => {
controller.abort()
}, COMPLETION_TIMEOUT)

const cleanup = () => {
clearTimeout(timeoutId)
controller.abort()
}

try {
const url = `${options.protocol}://${options.hostname}:${options.port}${options.path}`
const fetchOptions = {
Expand Down Expand Up @@ -85,11 +74,11 @@ export async function streamResponse(request: StreamRequest) {
if (done) break
}

cleanup()
controller.abort()
onEnd?.()
reader.releaseLock()
} catch (error: unknown) {
cleanup()
controller.abort()
if (error instanceof Error) {
if (error.name === 'AbortError') {
onEnd?.()
Expand Down

0 comments on commit 901d83e

Please sign in to comment.