@honeybadger-io/nextjs 5.10.13 → 5.11.0
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/README.md +8 -0
- package/dist/edge.d.ts +2 -0
- package/dist/honeybadger-nextjs-edge.cjs.js +384 -0
- package/dist/honeybadger-nextjs-edge.cjs.js.map +1 -0
- package/dist/honeybadger-nextjs-edge.esm.js +357 -0
- package/dist/honeybadger-nextjs-edge.esm.js.map +1 -0
- package/dist/honeybadger-nextjs.cjs.js +334 -14
- package/dist/honeybadger-nextjs.cjs.js.map +1 -1
- package/dist/honeybadger-nextjs.esm.js +315 -14
- package/dist/honeybadger-nextjs.esm.js.map +1 -1
- package/dist/insights-instrumentation.d.ts +17 -0
- package/dist/with-honeybadger.d.ts +28 -3
- package/dist/with-honeybadger.test.d.ts +2 -0
- package/package.json +33 -6
- package/src/copy-config-files.test.ts +9 -0
- package/src/edge.ts +1 -0
- package/src/insights-instrumentation.ts +155 -0
- package/src/with-honeybadger.test.ts +527 -0
- package/src/with-honeybadger.ts +242 -12
- package/templates/honeybadger.browser.config.js +4 -2
- package/templates/honeybadger.edge.config.js +4 -2
- package/templates/honeybadger.server.config.js +11 -8
package/README.md
CHANGED
|
@@ -43,6 +43,14 @@ The following limitations are known to exist and will be tackled in future relea
|
|
|
43
43
|
since Next.js will send a [generic error message](https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-server-errors) to this component for better security.
|
|
44
44
|
- [Issue link](https://github.com/honeybadger-io/honeybadger-js/issues/1056): Source maps for the [Edge runtime](https://vercel.com/docs/concepts/functions/edge-functions/edge-runtime) are not supported yet.
|
|
45
45
|
|
|
46
|
+
## API routes and edge runtime
|
|
47
|
+
|
|
48
|
+
API routes (`pages/api/*`, `app/api/*`) and edge middleware are not reached by the
|
|
49
|
+
webpack config-file auto-injection. Pass an explicit config as the second argument
|
|
50
|
+
to `withHoneybadger` there — see the
|
|
51
|
+
[Next.js integration guide](https://docs.honeybadger.io/lib/javascript/integration/nextjs)
|
|
52
|
+
for details.
|
|
53
|
+
|
|
46
54
|
## Example app
|
|
47
55
|
|
|
48
56
|
A separate repository, [nextjs-with-honeybadger](https://github.com/honeybadger-io/nextjs-with-honeybadger) exists with an example app using this package.
|
package/dist/edge.d.ts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Honeybadger = require('@honeybadger-io/js');
|
|
6
|
+
var nextServer = require('next/server');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n["default"] = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
|
|
29
|
+
var nextServer__namespace = /*#__PURE__*/_interopNamespace(nextServer);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Edge-safe equivalents of the inbound instrumentation helpers in
|
|
33
|
+
* `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are
|
|
34
|
+
* duplicated here because this module must also load on the edge runtime where
|
|
35
|
+
* Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep
|
|
36
|
+
* the header names and the `request_id` / `correlation_id` contract in sync
|
|
37
|
+
* with that file.
|
|
38
|
+
*
|
|
39
|
+
* Both request shapes Next.js uses are supported: the `*RequestEventContext` /
|
|
40
|
+
* `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router
|
|
41
|
+
* route handlers and middleware) and a Node-bag variant (Pages Router API
|
|
42
|
+
* routes, which only ever run on the Node runtime).
|
|
43
|
+
*/
|
|
44
|
+
function generateId() {
|
|
45
|
+
const webCrypto = globalThis.crypto;
|
|
46
|
+
if (webCrypto && typeof webCrypto.randomUUID === 'function') {
|
|
47
|
+
try {
|
|
48
|
+
return webCrypto.randomUUID();
|
|
49
|
+
}
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
+
catch (error) {
|
|
52
|
+
// fall through to manual generation
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// v4-shaped, not crypto-quality. Acceptable since this is a correlation id,
|
|
56
|
+
// not a security token.
|
|
57
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {
|
|
58
|
+
const r = (Math.random() * 16) | 0;
|
|
59
|
+
const v = ch === 'x' ? r : (r & 0x3) | 0x8;
|
|
60
|
+
return v.toString(16);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function readHeader(headers, name) {
|
|
64
|
+
const value = headers.get(name);
|
|
65
|
+
if (typeof value !== 'string') {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const trimmed = value.trim();
|
|
69
|
+
return trimmed.length ? trimmed : undefined;
|
|
70
|
+
}
|
|
71
|
+
function readNodeHeader(headers, name) {
|
|
72
|
+
if (!headers) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const lower = name.toLowerCase();
|
|
76
|
+
let value = headers[lower];
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
for (const key of Object.keys(headers)) {
|
|
79
|
+
if (key.toLowerCase() === lower) {
|
|
80
|
+
value = headers[key];
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
value = value[0];
|
|
87
|
+
}
|
|
88
|
+
if (typeof value !== 'string') {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const trimmed = value.trim();
|
|
92
|
+
return trimmed.length ? trimmed : undefined;
|
|
93
|
+
}
|
|
94
|
+
// Shared id precedence. Kept in one place (rather than once per request shape)
|
|
95
|
+
// so the header-name contract documented above is only spelled out once.
|
|
96
|
+
function seedIds(read) {
|
|
97
|
+
var _a, _b, _c, _d;
|
|
98
|
+
const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();
|
|
99
|
+
const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;
|
|
100
|
+
return { request_id: requestId, correlation_id: correlationId };
|
|
101
|
+
}
|
|
102
|
+
// App Router / middleware: headers are a web `Headers` instance.
|
|
103
|
+
function seedRequestEventContext(headers) {
|
|
104
|
+
return seedIds((name) => readHeader(headers, name));
|
|
105
|
+
}
|
|
106
|
+
// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).
|
|
107
|
+
function seedNodeRequestEventContext(headers) {
|
|
108
|
+
return seedIds((name) => readNodeHeader(headers, name));
|
|
109
|
+
}
|
|
110
|
+
function now() {
|
|
111
|
+
return typeof performance !== 'undefined' ? performance.now() : Date.now();
|
|
112
|
+
}
|
|
113
|
+
// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and
|
|
114
|
+
// the per-source flag must both be on.
|
|
115
|
+
function insightsHttpEnabled() {
|
|
116
|
+
const insights = Honeybadger__default["default"].config.insights;
|
|
117
|
+
return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;
|
|
118
|
+
}
|
|
119
|
+
// The ids are embedded directly in the payload (instead of relying on the
|
|
120
|
+
// store's eventContext merge) so the event carries them even on the edge
|
|
121
|
+
// runtime, where there is no per-request store isolation. On the Node.js
|
|
122
|
+
// runtime they match the seeded event context, so embedding is a no-op.
|
|
123
|
+
function emitHandledEvent(method, path, status, start, ids) {
|
|
124
|
+
const payload = {
|
|
125
|
+
method,
|
|
126
|
+
duration: Math.round(now() - start),
|
|
127
|
+
...ids,
|
|
128
|
+
};
|
|
129
|
+
if (typeof path === 'string') {
|
|
130
|
+
payload.path = path;
|
|
131
|
+
}
|
|
132
|
+
if (typeof status === 'number') {
|
|
133
|
+
payload.status = status;
|
|
134
|
+
}
|
|
135
|
+
Honeybadger__default["default"].event('request.handled', payload);
|
|
136
|
+
}
|
|
137
|
+
// App Router / middleware: `req.url` is absolute, so parse out the pathname.
|
|
138
|
+
function emitRequestEvent(req, status, start, ids) {
|
|
139
|
+
let path;
|
|
140
|
+
try {
|
|
141
|
+
path = new URL(req.url).pathname;
|
|
142
|
+
}
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
|
+
catch (error) {
|
|
145
|
+
// relative or malformed URL — leave path unset
|
|
146
|
+
}
|
|
147
|
+
emitHandledEvent(req.method, path, status, start, ids);
|
|
148
|
+
}
|
|
149
|
+
// Pages Router: `req.url` is a relative path that may carry a query string.
|
|
150
|
+
function emitNodeRequestEvent(req, status, start, ids) {
|
|
151
|
+
const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;
|
|
152
|
+
emitHandledEvent(req.method, path, status, start, ids);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The `waitUntil` primitive the hosting platform injects per request. Next.js
|
|
157
|
+
* resolves `after()` through this same accessor, and it is the only channel
|
|
158
|
+
* available in Pages Router API routes, which are invoked as `(req, res)` with
|
|
159
|
+
* no context argument to read it from.
|
|
160
|
+
*/
|
|
161
|
+
function requestContextWaitUntil() {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const context = globalThis[Symbol.for('@next/request-context')];
|
|
164
|
+
const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;
|
|
165
|
+
return typeof waitUntil === 'function' ? waitUntil : undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Middleware receives a `NextFetchEvent` as its second argument. Duck-typed
|
|
169
|
+
* rather than `instanceof` so the edge bundle needs no runtime import, and
|
|
170
|
+
* bound because `waitUntil` is a class method that collects into the event.
|
|
171
|
+
*/
|
|
172
|
+
function eventWaitUntil(event) {
|
|
173
|
+
const waitUntil = event === null || event === void 0 ? void 0 : event.waitUntil;
|
|
174
|
+
return typeof waitUntil === 'function' ? waitUntil.bind(event) : undefined;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Ensure Insights events are delivered before the serverless/edge runtime
|
|
178
|
+
* freezes, without delaying the response where the runtime lets us avoid it.
|
|
179
|
+
*
|
|
180
|
+
* In order of preference: Next.js `after()` (stable in 15.1, App Router only —
|
|
181
|
+
* it needs App Router request context, so Pages Router must not call it), then
|
|
182
|
+
* a `waitUntil` from the middleware event or the platform request context,
|
|
183
|
+
* then a blocking `flushAsync()` when the runtime offers neither. Blocking is
|
|
184
|
+
* correct in that last case: no `waitUntil` means nothing is going to freeze
|
|
185
|
+
* the invocation out from under us.
|
|
186
|
+
*
|
|
187
|
+
* Delivery failures are logged by the events worker and must not break the handler.
|
|
188
|
+
*/
|
|
189
|
+
function scheduleFlush(options = {}) {
|
|
190
|
+
var _a;
|
|
191
|
+
const flush = () => Honeybadger__default["default"].flushAsync().catch(() => { });
|
|
192
|
+
if (options.useAfter) {
|
|
193
|
+
const after = nextServer__namespace.after;
|
|
194
|
+
if (typeof after === 'function') {
|
|
195
|
+
// Exported but still refusable: `after()` throws outside a supported
|
|
196
|
+
// context. Fall through to the remaining strategies rather than failing
|
|
197
|
+
// the request.
|
|
198
|
+
try {
|
|
199
|
+
after(flush);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
203
|
+
catch (error) {
|
|
204
|
+
// try waitUntil / blocking flush below
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();
|
|
209
|
+
if (waitUntil) {
|
|
210
|
+
waitUntil(flush());
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
return flush();
|
|
214
|
+
}
|
|
215
|
+
function configure(overrides) {
|
|
216
|
+
var _a;
|
|
217
|
+
if (((_a = Honeybadger__default["default"].config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let projectRoot = undefined;
|
|
221
|
+
try {
|
|
222
|
+
// not available on edge runtime
|
|
223
|
+
projectRoot = process.cwd();
|
|
224
|
+
}
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
226
|
+
catch (error) {
|
|
227
|
+
// do nothing
|
|
228
|
+
}
|
|
229
|
+
Honeybadger__default["default"]
|
|
230
|
+
.configure({
|
|
231
|
+
apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,
|
|
232
|
+
environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,
|
|
233
|
+
revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,
|
|
234
|
+
projectRoot: 'webpack://_N_E/./',
|
|
235
|
+
...overrides,
|
|
236
|
+
})
|
|
237
|
+
.beforeNotify((notice) => {
|
|
238
|
+
if (!projectRoot) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {
|
|
242
|
+
if (line.file) {
|
|
243
|
+
line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);
|
|
244
|
+
}
|
|
245
|
+
return line;
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,
|
|
251
|
+
* `forbidden()` and `unauthorized()` all throw an error carrying a `digest`
|
|
252
|
+
* string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).
|
|
253
|
+
* These are not real failures — the framework catches them upstream to produce
|
|
254
|
+
* the redirect/404/etc. — so we must let them propagate without reporting them,
|
|
255
|
+
* otherwise every redirect shows up as an error in Honeybadger.
|
|
256
|
+
*
|
|
257
|
+
* We match on the `NEXT_` prefix rather than an exhaustive list so that any
|
|
258
|
+
* present or future framework control-flow digest is covered. This is safe:
|
|
259
|
+
* genuine errors that React tags with a `digest` use an opaque hash, and other
|
|
260
|
+
* Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,
|
|
261
|
+
* `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.
|
|
262
|
+
*/
|
|
263
|
+
function isNextControlFlowError(error) {
|
|
264
|
+
const digest = error === null || error === void 0 ? void 0 : error.digest;
|
|
265
|
+
return typeof digest === 'string' && digest.startsWith('NEXT_');
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Detects a Pages Router API invocation: `(req, res)` where `res` is a Node
|
|
269
|
+
* `ServerResponse`. We branch on this structurally because — unlike an App
|
|
270
|
+
* Router route handler — there is no returned `Response` to read the status
|
|
271
|
+
* from; it lives on `res.statusCode`.
|
|
272
|
+
*/
|
|
273
|
+
function isPagesApiInvocation(args) {
|
|
274
|
+
const req = args[0];
|
|
275
|
+
const res = args[1];
|
|
276
|
+
return (!!req && typeof req.headers === 'object' && req.headers !== null &&
|
|
277
|
+
!!res && typeof res.statusCode === 'number' && typeof res.end === 'function');
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* App Router route handlers and middleware: a web `Request`/`NextRequest` in, a
|
|
281
|
+
* `Response`/`NextResponse` out. The status comes from the returned response.
|
|
282
|
+
*
|
|
283
|
+
* `waitUntil` is present for middleware (from its `NextFetchEvent`); route
|
|
284
|
+
* handlers get `{ params }` as their second argument and rely on `after()`.
|
|
285
|
+
*/
|
|
286
|
+
async function handleAppRouterRequest(call, req, canIsolate, waitUntil) {
|
|
287
|
+
const ids = seedRequestEventContext(req.headers);
|
|
288
|
+
if (canIsolate) {
|
|
289
|
+
Honeybadger__default["default"].setEventContext(ids);
|
|
290
|
+
}
|
|
291
|
+
const start = insightsHttpEnabled() ? now() : null;
|
|
292
|
+
try {
|
|
293
|
+
const response = await call();
|
|
294
|
+
if (start !== null) {
|
|
295
|
+
emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);
|
|
296
|
+
await scheduleFlush({ useAfter: true, waitUntil });
|
|
297
|
+
}
|
|
298
|
+
return response;
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
if (isNextControlFlowError(error)) {
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
if (start !== null) {
|
|
305
|
+
emitRequestEvent(req, 500, start, ids);
|
|
306
|
+
await scheduleFlush({ useAfter: true, waitUntil });
|
|
307
|
+
}
|
|
308
|
+
await Honeybadger__default["default"].notifyAsync(error);
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`
|
|
314
|
+
* and returns nothing meaningful, so the final status is read from
|
|
315
|
+
* `res.statusCode` once it resolves.
|
|
316
|
+
*/
|
|
317
|
+
async function handlePagesApiRequest(call, req, res, canIsolate) {
|
|
318
|
+
const ids = seedNodeRequestEventContext(req.headers);
|
|
319
|
+
if (canIsolate) {
|
|
320
|
+
Honeybadger__default["default"].setEventContext(ids);
|
|
321
|
+
}
|
|
322
|
+
const start = insightsHttpEnabled() ? now() : null;
|
|
323
|
+
try {
|
|
324
|
+
const result = await call();
|
|
325
|
+
if (start !== null) {
|
|
326
|
+
emitNodeRequestEvent(req, res.statusCode, start, ids);
|
|
327
|
+
// No after() here: Pages Router lacks the App Router request context it
|
|
328
|
+
// needs. scheduleFlush falls through to the platform waitUntil instead.
|
|
329
|
+
await scheduleFlush({ useAfter: false });
|
|
330
|
+
}
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
if (isNextControlFlowError(error)) {
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
337
|
+
if (start !== null) {
|
|
338
|
+
emitNodeRequestEvent(req, 500, start, ids);
|
|
339
|
+
await scheduleFlush({ useAfter: false });
|
|
340
|
+
}
|
|
341
|
+
await Honeybadger__default["default"].notifyAsync(error);
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Unrecognised invocation shape: still report errors, but emit no insights
|
|
347
|
+
* event since we can't reliably read the request.
|
|
348
|
+
*/
|
|
349
|
+
async function handleUninstrumented(call) {
|
|
350
|
+
try {
|
|
351
|
+
return await call();
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
if (isNextControlFlowError(error)) {
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
await Honeybadger__default["default"].notifyAsync(error);
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function withHoneybadger(handler, config) {
|
|
362
|
+
configure(config);
|
|
363
|
+
return new Proxy(handler, {
|
|
364
|
+
apply: (target, thisArg, args) => {
|
|
365
|
+
const canIsolate = typeof Honeybadger__default["default"].run === 'function';
|
|
366
|
+
const call = () => Reflect.apply(target, thisArg, args);
|
|
367
|
+
const invoke = () => {
|
|
368
|
+
// App Router / middleware first: a web Request as the first argument.
|
|
369
|
+
if (typeof Request !== 'undefined' && args[0] instanceof Request) {
|
|
370
|
+
return handleAppRouterRequest(call, args[0], canIsolate, eventWaitUntil(args[1]));
|
|
371
|
+
}
|
|
372
|
+
// Pages Router API route: a Node req/res pair.
|
|
373
|
+
if (isPagesApiInvocation(args)) {
|
|
374
|
+
return handlePagesApiRequest(call, args[0], args[1], canIsolate);
|
|
375
|
+
}
|
|
376
|
+
return handleUninstrumented(call);
|
|
377
|
+
};
|
|
378
|
+
return canIsolate ? Honeybadger__default["default"].run(invoke) : invoke();
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
exports.withHoneybadger = withHoneybadger;
|
|
384
|
+
//# sourceMappingURL=honeybadger-nextjs-edge.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honeybadger-nextjs-edge.cjs.js","sources":["../../build/insights-instrumentation.js","../../build/with-honeybadger.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js';\n/**\n * Edge-safe equivalents of the inbound instrumentation helpers in\n * `@honeybadger-io/js` (src/server/instrumentation/http_event.ts). They are\n * duplicated here because this module must also load on the edge runtime where\n * Node builtins (the `crypto` module, `process.hrtime`) are unavailable. Keep\n * the header names and the `request_id` / `correlation_id` contract in sync\n * with that file.\n *\n * Both request shapes Next.js uses are supported: the `*RequestEventContext` /\n * `*RequestEvent` pairs come in a web-`Headers`/`Request` variant (App Router\n * route handlers and middleware) and a Node-bag variant (Pages Router API\n * routes, which only ever run on the Node runtime).\n */\nfunction generateId() {\n const webCrypto = globalThis.crypto;\n if (webCrypto && typeof webCrypto.randomUUID === 'function') {\n try {\n return webCrypto.randomUUID();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // fall through to manual generation\n }\n }\n // v4-shaped, not crypto-quality. Acceptable since this is a correlation id,\n // not a security token.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nfunction readHeader(headers, name) {\n const value = headers.get(name);\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\nfunction readNodeHeader(headers, name) {\n if (!headers) {\n return undefined;\n }\n const lower = name.toLowerCase();\n let value = headers[lower];\n if (value === undefined) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === lower) {\n value = headers[key];\n break;\n }\n }\n }\n if (Array.isArray(value)) {\n value = value[0];\n }\n if (typeof value !== 'string') {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length ? trimmed : undefined;\n}\n// Shared id precedence. Kept in one place (rather than once per request shape)\n// so the header-name contract documented above is only spelled out once.\nfunction seedIds(read) {\n var _a, _b, _c, _d;\n const requestId = (_b = (_a = read('x-request-id')) !== null && _a !== void 0 ? _a : read('request-id')) !== null && _b !== void 0 ? _b : generateId();\n const correlationId = (_d = (_c = read('x-correlation-id')) !== null && _c !== void 0 ? _c : read('x-amzn-trace-id')) !== null && _d !== void 0 ? _d : requestId;\n return { request_id: requestId, correlation_id: correlationId };\n}\n// App Router / middleware: headers are a web `Headers` instance.\nexport function seedRequestEventContext(headers) {\n return seedIds((name) => readHeader(headers, name));\n}\n// Pages Router: headers are a Node bag (Pages routes are Node-only, never edge).\nexport function seedNodeRequestEventContext(headers) {\n return seedIds((name) => readNodeHeader(headers, name));\n}\nexport function now() {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n// Mirrors Util.resolveInsights from @honeybadger-io/core: the master gate and\n// the per-source flag must both be on.\nexport function insightsHttpEnabled() {\n const insights = Honeybadger.config.insights;\n return (insights === null || insights === void 0 ? void 0 : insights.enabled) === true && (insights === null || insights === void 0 ? void 0 : insights.http) === true;\n}\n// The ids are embedded directly in the payload (instead of relying on the\n// store's eventContext merge) so the event carries them even on the edge\n// runtime, where there is no per-request store isolation. On the Node.js\n// runtime they match the seeded event context, so embedding is a no-op.\nfunction emitHandledEvent(method, path, status, start, ids) {\n const payload = {\n method,\n duration: Math.round(now() - start),\n ...ids,\n };\n if (typeof path === 'string') {\n payload.path = path;\n }\n if (typeof status === 'number') {\n payload.status = status;\n }\n Honeybadger.event('request.handled', payload);\n}\n// App Router / middleware: `req.url` is absolute, so parse out the pathname.\nexport function emitRequestEvent(req, status, start, ids) {\n let path;\n try {\n path = new URL(req.url).pathname;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // relative or malformed URL — leave path unset\n }\n emitHandledEvent(req.method, path, status, start, ids);\n}\n// Pages Router: `req.url` is a relative path that may carry a query string.\nexport function emitNodeRequestEvent(req, status, start, ids) {\n const path = typeof req.url === 'string' ? req.url.split('?')[0] : undefined;\n emitHandledEvent(req.method, path, status, start, ids);\n}\n//# sourceMappingURL=insights-instrumentation.js.map","import Honeybadger from '@honeybadger-io/js';\nimport * as nextServer from 'next/server';\nimport { emitNodeRequestEvent, emitRequestEvent, insightsHttpEnabled, now, seedNodeRequestEventContext, seedRequestEventContext, } from './insights-instrumentation';\n/**\n * The `waitUntil` primitive the hosting platform injects per request. Next.js\n * resolves `after()` through this same accessor, and it is the only channel\n * available in Pages Router API routes, which are invoked as `(req, res)` with\n * no context argument to read it from.\n */\nfunction requestContextWaitUntil() {\n var _a, _b;\n const context = globalThis[Symbol.for('@next/request-context')];\n const waitUntil = (_b = (_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil : undefined;\n}\n/**\n * Middleware receives a `NextFetchEvent` as its second argument. Duck-typed\n * rather than `instanceof` so the edge bundle needs no runtime import, and\n * bound because `waitUntil` is a class method that collects into the event.\n */\nfunction eventWaitUntil(event) {\n const waitUntil = event === null || event === void 0 ? void 0 : event.waitUntil;\n return typeof waitUntil === 'function' ? waitUntil.bind(event) : undefined;\n}\n/**\n * Ensure Insights events are delivered before the serverless/edge runtime\n * freezes, without delaying the response where the runtime lets us avoid it.\n *\n * In order of preference: Next.js `after()` (stable in 15.1, App Router only —\n * it needs App Router request context, so Pages Router must not call it), then\n * a `waitUntil` from the middleware event or the platform request context,\n * then a blocking `flushAsync()` when the runtime offers neither. Blocking is\n * correct in that last case: no `waitUntil` means nothing is going to freeze\n * the invocation out from under us.\n *\n * Delivery failures are logged by the events worker and must not break the handler.\n */\nfunction scheduleFlush(options = {}) {\n var _a;\n const flush = () => Honeybadger.flushAsync().catch(() => { });\n if (options.useAfter) {\n const after = nextServer.after;\n if (typeof after === 'function') {\n // Exported but still refusable: `after()` throws outside a supported\n // context. Fall through to the remaining strategies rather than failing\n // the request.\n try {\n after(flush);\n return;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // try waitUntil / blocking flush below\n }\n }\n }\n const waitUntil = (_a = options.waitUntil) !== null && _a !== void 0 ? _a : requestContextWaitUntil();\n if (waitUntil) {\n waitUntil(flush());\n return;\n }\n return flush();\n}\nfunction configure(overrides) {\n var _a;\n if (((_a = Honeybadger.config.apiKey) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n return;\n }\n let projectRoot = undefined;\n try {\n // not available on edge runtime\n projectRoot = process.cwd();\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n catch (error) {\n // do nothing\n }\n Honeybadger\n .configure({\n apiKey: process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY,\n environment: process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.VERCEL_ENV || process.env.NODE_ENV,\n revision: process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n projectRoot: 'webpack://_N_E/./',\n ...overrides,\n })\n .beforeNotify((notice) => {\n if (!projectRoot) {\n return;\n }\n notice === null || notice === void 0 ? void 0 : notice.backtrace.forEach((line) => {\n if (line.file) {\n line.file = line.file.replace(`${projectRoot}/.next/server`, `${process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL}/..`);\n }\n return line;\n });\n });\n}\n/**\n * Next.js uses thrown errors for control flow: `redirect()`, `notFound()`,\n * `forbidden()` and `unauthorized()` all throw an error carrying a `digest`\n * string (`NEXT_REDIRECT;...`, `NEXT_NOT_FOUND`, `NEXT_HTTP_ERROR_FALLBACK;...`).\n * These are not real failures — the framework catches them upstream to produce\n * the redirect/404/etc. — so we must let them propagate without reporting them,\n * otherwise every redirect shows up as an error in Honeybadger.\n *\n * We match on the `NEXT_` prefix rather than an exhaustive list so that any\n * present or future framework control-flow digest is covered. This is safe:\n * genuine errors that React tags with a `digest` use an opaque hash, and other\n * Next.js bailout signals (e.g. `BAILOUT_TO_CLIENT_SIDE_RENDERING`,\n * `DYNAMIC_SERVER_USAGE`) are not `NEXT_`-prefixed, so neither is skipped.\n */\nfunction isNextControlFlowError(error) {\n const digest = error === null || error === void 0 ? void 0 : error.digest;\n return typeof digest === 'string' && digest.startsWith('NEXT_');\n}\n/**\n * Detects a Pages Router API invocation: `(req, res)` where `res` is a Node\n * `ServerResponse`. We branch on this structurally because — unlike an App\n * Router route handler — there is no returned `Response` to read the status\n * from; it lives on `res.statusCode`.\n */\nfunction isPagesApiInvocation(args) {\n const req = args[0];\n const res = args[1];\n return (!!req && typeof req.headers === 'object' && req.headers !== null &&\n !!res && typeof res.statusCode === 'number' && typeof res.end === 'function');\n}\n/**\n * App Router route handlers and middleware: a web `Request`/`NextRequest` in, a\n * `Response`/`NextResponse` out. The status comes from the returned response.\n *\n * `waitUntil` is present for middleware (from its `NextFetchEvent`); route\n * handlers get `{ params }` as their second argument and rely on `after()`.\n */\nasync function handleAppRouterRequest(call, req, canIsolate, waitUntil) {\n const ids = seedRequestEventContext(req.headers);\n if (canIsolate) {\n Honeybadger.setEventContext(ids);\n }\n const start = insightsHttpEnabled() ? now() : null;\n try {\n const response = await call();\n if (start !== null) {\n emitRequestEvent(req, response === null || response === void 0 ? void 0 : response.status, start, ids);\n await scheduleFlush({ useAfter: true, waitUntil });\n }\n return response;\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n if (start !== null) {\n emitRequestEvent(req, 500, start, ids);\n await scheduleFlush({ useAfter: true, waitUntil });\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\n/**\n * Pages Router API routes: a Node `req`/`res` pair. The handler writes to `res`\n * and returns nothing meaningful, so the final status is read from\n * `res.statusCode` once it resolves.\n */\nasync function handlePagesApiRequest(call, req, res, canIsolate) {\n const ids = seedNodeRequestEventContext(req.headers);\n if (canIsolate) {\n Honeybadger.setEventContext(ids);\n }\n const start = insightsHttpEnabled() ? now() : null;\n try {\n const result = await call();\n if (start !== null) {\n emitNodeRequestEvent(req, res.statusCode, start, ids);\n // No after() here: Pages Router lacks the App Router request context it\n // needs. scheduleFlush falls through to the platform waitUntil instead.\n await scheduleFlush({ useAfter: false });\n }\n return result;\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n if (start !== null) {\n emitNodeRequestEvent(req, 500, start, ids);\n await scheduleFlush({ useAfter: false });\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\n/**\n * Unrecognised invocation shape: still report errors, but emit no insights\n * event since we can't reliably read the request.\n */\nasync function handleUninstrumented(call) {\n try {\n return await call();\n }\n catch (error) {\n if (isNextControlFlowError(error)) {\n throw error;\n }\n await Honeybadger.notifyAsync(error);\n throw error;\n }\n}\nexport function withHoneybadger(handler, config) {\n configure(config);\n return new Proxy(handler, {\n apply: (target, thisArg, args) => {\n const canIsolate = typeof Honeybadger.run === 'function';\n const call = () => Reflect.apply(target, thisArg, args);\n const invoke = () => {\n // App Router / middleware first: a web Request as the first argument.\n if (typeof Request !== 'undefined' && args[0] instanceof Request) {\n return handleAppRouterRequest(call, args[0], canIsolate, eventWaitUntil(args[1]));\n }\n // Pages Router API route: a Node req/res pair.\n if (isPagesApiInvocation(args)) {\n return handlePagesApiRequest(call, args[0], args[1], canIsolate);\n }\n return handleUninstrumented(call);\n };\n return canIsolate ? Honeybadger.run(invoke) : invoke();\n },\n });\n}\n//# sourceMappingURL=with-honeybadger.js.map"],"names":["Honeybadger","nextServer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,GAAG;AACtB,IAAI,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC;AACxC,IAAI,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,EAAE;AACjE,QAAQ,IAAI;AACZ,YAAY,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC;AAC1C,SAAS;AACT;AACA,QAAQ,OAAO,KAAK,EAAE;AACtB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA,IAAI,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK;AAC3E,QAAQ,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3C,QAAQ,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC;AACnD,QAAQ,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC9B,KAAK,CAAC,CAAC;AACP,CAAC;AACD,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpC,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACnC,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;AACjC,IAAI,OAA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