@telorun/http-server 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @telorun/http-server
2
2
 
3
+ ## 0.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a33b8cc: Log mid-stream failures server-side. When a `mode: stream` route's stream throws
8
+ after the response headers are flushed, the failure can't reach Fastify's error
9
+ handler or a `catches:` entry, so it was previously silent for the operator (it
10
+ was only emitted as an `Http.Api.streamFailed` event, which nothing logs unless a
11
+ debug consumer is attached). The stream-error hook now also logs on the server's
12
+ request logger (the one `Http.Server.logger` configures) at `error` level with
13
+ the error, route, status, and MIME. Client-facing behaviour is unchanged.
14
+ - @telorun/http-dispatch@0.4.1
15
+
3
16
  ## 0.15.1
4
17
 
5
18
  ### Patch Changes
@@ -165,15 +165,28 @@ export class HttpServerApi {
165
165
  return dispatchCatches(route.catches, { code: err.code, message: err.message, data: err.data }, requestContext, acceptHeader, this.ctx.moduleContext, this.ctx.validateSchema.bind(this.ctx), sink);
166
166
  }
167
167
  await span.settle("ok");
168
- return dispatchReturns(route.returns, result, requestContext, acceptHeader, this.ctx.moduleContext, this.ctx.validateSchema.bind(this.ctx), sink, (err, errCtx) => this.ctx.emitEvent("Http.Api.streamFailed", {
169
- path: route.request.path,
170
- method: route.request.method,
171
- status: errCtx.status,
172
- mime: errCtx.mime,
173
- error: err instanceof Error
174
- ? { message: err.message, stack: err.stack, code: err.code }
175
- : { message: String(err) },
176
- }));
168
+ return dispatchReturns(route.returns, result, requestContext, acceptHeader, this.ctx.moduleContext, this.ctx.validateSchema.bind(this.ctx), sink, (err, errCtx) => {
169
+ // Headers are already flushed, so this failure can't reach Fastify's
170
+ // error handler (which logs pre-stream throws) — log it here, on the
171
+ // same request logger `logger:` configures, so a mid-stream failure
172
+ // isn't silent server-side. The event below stays for debug tooling.
173
+ reply.log.error({
174
+ err,
175
+ path: route.request.path,
176
+ method: route.request.method,
177
+ status: errCtx.status,
178
+ mime: errCtx.mime,
179
+ }, "Http.Api stream failed after response headers were flushed");
180
+ return this.ctx.emitEvent("Http.Api.streamFailed", {
181
+ path: route.request.path,
182
+ method: route.request.method,
183
+ status: errCtx.status,
184
+ mime: errCtx.mime,
185
+ error: err instanceof Error
186
+ ? { message: err.message, stack: err.stack, code: err.code }
187
+ : { message: String(err) },
188
+ });
189
+ });
177
190
  },
178
191
  });
179
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/http-server",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Telo HTTP Server module - HTTP server and API resource kinds for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -55,7 +55,7 @@
55
55
  "@types/node": "^20.0.0",
56
56
  "typescript": "^5.0.0",
57
57
  "vitest": "^2.1.8",
58
- "@telorun/sdk": "0.38.0"
58
+ "@telorun/sdk": "0.44.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@telorun/sdk": "*"
@@ -222,8 +222,22 @@ export class HttpServerApi implements ResourceInstance {
222
222
  this.ctx.moduleContext,
223
223
  this.ctx.validateSchema.bind(this.ctx),
224
224
  sink,
225
- (err, errCtx) =>
226
- this.ctx.emitEvent("Http.Api.streamFailed", {
225
+ (err, errCtx) => {
226
+ // Headers are already flushed, so this failure can't reach Fastify's
227
+ // error handler (which logs pre-stream throws) — log it here, on the
228
+ // same request logger `logger:` configures, so a mid-stream failure
229
+ // isn't silent server-side. The event below stays for debug tooling.
230
+ reply.log.error(
231
+ {
232
+ err,
233
+ path: route.request.path,
234
+ method: route.request.method,
235
+ status: errCtx.status,
236
+ mime: errCtx.mime,
237
+ },
238
+ "Http.Api stream failed after response headers were flushed",
239
+ );
240
+ return this.ctx.emitEvent("Http.Api.streamFailed", {
227
241
  path: route.request.path,
228
242
  method: route.request.method,
229
243
  status: errCtx.status,
@@ -232,7 +246,8 @@ export class HttpServerApi implements ResourceInstance {
232
246
  err instanceof Error
233
247
  ? { message: err.message, stack: err.stack, code: (err as { code?: string }).code }
234
248
  : { message: String(err) },
235
- }),
249
+ });
250
+ },
236
251
  );
237
252
  },
238
253
  });