+2
-1
packages/appview/src/index.ts
+2
-1
packages/appview/src/index.ts
···
120
async close() {
121
this.ctx.logger.info('sigint received, shutting down')
122
await this.ctx.ingester.destroy()
123
-
return new Promise<void>((resolve) => {
124
this.server.close(() => {
125
this.ctx.logger.info('server closed')
126
resolve()
···
135
const onCloseSignal = async () => {
136
setTimeout(() => process.exit(1), 10000).unref() // Force shutdown after 10s
137
await server.close()
138
}
139
140
process.on('SIGINT', onCloseSignal)
···
120
async close() {
121
this.ctx.logger.info('sigint received, shutting down')
122
await this.ctx.ingester.destroy()
123
+
await new Promise<void>((resolve) => {
124
this.server.close(() => {
125
this.ctx.logger.info('server closed')
126
resolve()
···
135
const onCloseSignal = async () => {
136
setTimeout(() => process.exit(1), 10000).unref() // Force shutdown after 10s
137
await server.close()
138
+
process.exit(0)
139
}
140
141
process.on('SIGINT', onCloseSignal)
+6
-1
packages/appview/src/ingestors/jetstream.ts
+6
-1
packages/appview/src/ingestors/jetstream.ts
···
93
private cursor?: number
94
private ws?: WebSocket
95
private isStarted = false
96
private wantedCollections: string[]
97
98
constructor({
···
133
start() {
134
if (this.isStarted) return
135
this.isStarted = true
136
this.ws = new WebSocket(this.constructUrlWithQuery())
137
138
this.ws.on('open', () => {
···
159
})
160
161
this.ws.on('close', (code, reason) => {
162
-
this.logger.error(`Jetstream closed. Code: ${code}, Reason: ${reason}`)
163
this.isStarted = false
164
})
165
}
166
167
destroy() {
168
if (this.ws) {
169
this.ws.close()
170
this.isStarted = false
171
}
···
93
private cursor?: number
94
private ws?: WebSocket
95
private isStarted = false
96
+
private isDestroyed = false
97
private wantedCollections: string[]
98
99
constructor({
···
134
start() {
135
if (this.isStarted) return
136
this.isStarted = true
137
+
this.isDestroyed = false
138
this.ws = new WebSocket(this.constructUrlWithQuery())
139
140
this.ws.on('open', () => {
···
161
})
162
163
this.ws.on('close', (code, reason) => {
164
+
if (!this.isDestroyed) {
165
+
this.logger.error(`Jetstream closed. Code: ${code}, Reason: ${reason}`)
166
+
}
167
this.isStarted = false
168
})
169
}
170
171
destroy() {
172
if (this.ws) {
173
+
this.isDestroyed = true
174
this.ws.close()
175
this.isStarted = false
176
}