Buckets:
ktongue/docker_container / .cache /opencode /node_modules /fastify /test /diagnostics-channel /error-request.test.js
| const { test } = require('node:test') | |
| const diagnostics = require('node:diagnostics_channel') | |
| const Fastify = require('../..') | |
| const Request = require('../../lib/request') | |
| const Reply = require('../../lib/reply') | |
| test('diagnostics channel events report on errors', async t => { | |
| t.plan(14) | |
| let callOrder = 0 | |
| let firstEncounteredMessage | |
| diagnostics.subscribe('tracing:fastify.request.handler:start', (msg) => { | |
| t.assert.strictEqual(callOrder++, 0) | |
| firstEncounteredMessage = msg | |
| t.assert.ok(msg.request instanceof Request) | |
| t.assert.ok(msg.reply instanceof Reply) | |
| }) | |
| diagnostics.subscribe('tracing:fastify.request.handler:end', (msg) => { | |
| t.assert.ok(msg.request instanceof Request) | |
| t.assert.ok(msg.reply instanceof Reply) | |
| t.assert.strictEqual(callOrder++, 2) | |
| t.assert.strictEqual(msg, firstEncounteredMessage) | |
| }) | |
| diagnostics.subscribe('tracing:fastify.request.handler:error', (msg) => { | |
| t.assert.ok(msg.request instanceof Request) | |
| t.assert.ok(msg.reply instanceof Reply) | |
| t.assert.ok(msg.error instanceof Error) | |
| t.assert.strictEqual(callOrder++, 1) | |
| t.assert.strictEqual(msg.error.message, 'borked') | |
| }) | |
| const fastify = Fastify() | |
| fastify.route({ | |
| method: 'GET', | |
| url: '/', | |
| handler: function (req, reply) { | |
| throw new Error('borked') | |
| } | |
| }) | |
| const fastifyServer = await fastify.listen({ port: 0 }) | |
| t.after(() => { fastify.close() }) | |
| const response = await fetch(fastifyServer, { | |
| method: 'GET' | |
| }) | |
| t.assert.ok(!response.ok) | |
| t.assert.strictEqual(response.status, 500) | |
| }) | |
Xet Storage Details
- Size:
- 1.59 kB
- Xet hash:
- 58fcec082ee70f24e738fd7a0b1d6dc43bc110612bfdb5d6e9fd509001eddf01
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.