Skip to content

Commit

Permalink
Fix Build
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll committed Dec 16, 2024
1 parent b020847 commit b696654
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"devDependencies": {
"@sinonjs/fake-timers": "14.0.0",
"@types/eventsource": "1.1.15",
"@types/node": "22.10.2",
"@types/sinonjs__fake-timers": "8.1.5",
"@types/ws": "8.5.13",
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type EventSource from 'eventsource'
import { EventSource } from 'eventsource'
import Redis from 'ioredis'
import { Cache } from '../cache'
import { AdapterConfig, BaseAdapterSettings, SettingsDefinitionMap } from '../config'
Expand Down
12 changes: 9 additions & 3 deletions src/transports/sse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosRequestConfig } from 'axios'
import EventSource from 'eventsource'
import { EventSource } from 'eventsource'
import { EndpointContext } from '../adapter'
import { calculateHttpRequestKey } from '../cache'
import { makeLogger, sleep } from '../util'
Expand All @@ -13,7 +13,7 @@ const logger = makeLogger('SSETransport')

export interface SSEConfig {
url: string
eventSourceInitDict?: EventSource.EventSourceInitDict
headers?: Record<string, string>
}

/**
Expand Down Expand Up @@ -103,7 +103,13 @@ export class SseTransport<T extends SSETransportGenerics> extends StreamingTrans
logger.debug('No established connection and new subscriptions available, connecting to SSE')
const sseConfig = this.config.prepareSSEConnectionConfig(subscriptions.new, context)
this.providerDataStreamEstablished = Date.now()
this.sseConnection = new this.EventSource(sseConfig.url, sseConfig.eventSourceInitDict)
this.sseConnection = new this.EventSource(sseConfig.url, {
fetch: (input, init) =>
fetch(input, {
...init,
headers: { ...init?.headers, ...sseConfig.headers },
}),
})

const eventHandlerGenerator = (listener: (typeof this.config.eventListeners)[0]) => {
return (e: MessageEvent) => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"noImplicitThis": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"strict": true
"strict": true,
"skipLibCheck": true
},
"exclude": ["src/**/test/**/*"],
"include": ["./src/**/*"]
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,6 @@
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz"
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==

"@types/eventsource@1.1.15":
version "1.1.15"
resolved "https://registry.npmjs.org/@types/eventsource/-/eventsource-1.1.15.tgz"
integrity sha512-XQmGcbnxUNa06HR3VBVkc9+A2Vpi9ZyLJcdS5dwaQQ/4ZMWFO+5c90FnMUpbtMZwB/FChoYHwuVg8TvkECacTA==

"@types/hast@^3.0.4":
version "3.0.4"
resolved "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz"
Expand Down

0 comments on commit b696654

Please sign in to comment.