Skip to content

Commit ec7dd82

Browse files
committed
upgrade hapi to rc.1
1 parent e1d6b87 commit ec7dd82

15 files changed

+703
-670
lines changed

apps/hapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@hapi/hapi": "21.3.9",
19-
"@sentry/node": "8.0.0-beta.6",
19+
"@sentry/node": "8.0.0-rc.1",
2020
"dotenv": "^16.4.5"
2121
}
2222
}

apps/hapi/src/app.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ import Hapi from '@hapi/hapi';
1616

1717
dotenv.config({ path: './../../.env' });
1818

19-
const server = Hapi.server({
20-
port: 3030,
21-
host: 'localhost',
22-
});
23-
2419
declare global {
2520
namespace globalThis {
2621
var transactionIds: string[];
2722
}
2823
}
2924

3025
const init = async () => {
26+
const server = Hapi.server({
27+
port: 3030,
28+
host: 'localhost',
29+
});
30+
3131
server.route({
3232
method: 'GET',
3333
path: '/test-success',
@@ -137,10 +137,11 @@ const init = async () => {
137137
return { exceptionId };
138138
},
139139
});
140-
};
141140

142-
(async () => {
143-
init();
141+
// @ts-ignore
142+
await Sentry.setupHapiErrorHandler(server);
144143
await server.start();
145144
console.log('Server running on %s', server.info.uri);
146-
})();
145+
};
146+
147+
init();

payload-files/hapi/_test-error--event.json

Lines changed: 98 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"event_id": "[[ID1]]",
55
"sdk": {
66
"name": "sentry.javascript.node",
7-
"version": "8.0.0-beta.6"
7+
"version": "8.0.0-rc.1"
88
},
99
"sent_at": "[[ISODateString]]",
1010
"trace": {
@@ -58,7 +58,8 @@
5858
"version": "v20.12.1"
5959
},
6060
"trace": {
61-
"span_id": "[[ID3]]",
61+
"parent_span_id": "[[ID3]]",
62+
"span_id": "[[ID4]]",
6263
"trace_id": "[[ID2]]"
6364
}
6465
},
@@ -74,120 +75,101 @@
7475
"stacktrace": {
7576
"frames": [
7677
{
77-
"colno": 36,
78-
"context_line": " const result = await internals.handler(request, request.route.settings.handler);",
78+
"colno": 40,
79+
"context_line": " return this._asyncLocalStorage.run(context, cb, ...args);",
7980
"filename": "[[FILENAME1]]",
80-
"function": "exports.execute",
81+
"function": "SentryContextManager.with",
8182
"in_app": false,
82-
"lineno": 31,
83-
"module": "@hapi.hapi.lib:handler",
83+
"lineno": 33,
84+
"module": "@opentelemetry.context-async-hooks.build.src:AsyncLocalStorageContextManager",
8485
"post_context": [
85-
" if (result._takeover ||",
86-
" typeof result === 'symbol') {",
87-
"",
88-
" return result;",
8986
" }",
90-
"",
91-
" request._setResponse(result);"
87+
" enable() {",
88+
" return this;",
89+
" }",
90+
" disable() {",
91+
" this._asyncLocalStorage.disable();",
92+
" return this;"
9293
],
9394
"pre_context": [
94-
" }",
95-
" }",
96-
" }",
9795
" }",
98-
"",
99-
" // Handler",
100-
""
96+
" active() {",
97+
" var _a;",
98+
" return (_a = this._asyncLocalStorage.getStore()) !== null && _a !== void 0 ? _a : api_1.ROOT_CONTEXT;",
99+
" }",
100+
" with(context, fn, thisArg, ...args) {",
101+
" const cb = thisArg == null ? fn : fn.bind(thisArg);"
101102
]
102103
},
103104
{
104-
"colno": 48,
105-
"context_line": " let response = await request._core.toolkit.execute(method, request, { bind, realm, continue: 'null' });",
106-
"filename": "[[FILENAME1]]",
107-
"function": "internals.handler",
105+
"colno": 14,
106+
"filename": "[[FILENAME2]]",
107+
"function": "AsyncLocalStorage.run",
108108
"in_app": false,
109-
"lineno": 46,
110-
"module": "@hapi.hapi.lib:handler",
111-
"post_context": [
112-
"",
113-
" // Handler",
114-
"",
115-
" if (!pre) {",
116-
" if (response.isBoom) {",
117-
" request._log(['handler', 'error'], response);",
118-
" throw response;"
119-
],
120-
"pre_context": [
121-
"};",
122-
"",
123-
"",
124-
"internals.handler = async function (request, method, pre) {",
125-
"",
126-
" const bind = request.route.settings.bind;",
127-
" const realm = request.route.realm;"
128-
]
109+
"lineno": 346,
110+
"module": "node:async_hooks"
129111
},
130112
{
131-
"colno": 29,
132-
"context_line": " operation = method(request, h);",
133-
"filename": "[[FILENAME2]]",
134-
"function": "exports.Manager.execute",
113+
"colno": 115,
114+
"context_line": " return await api.context.with(api.trace.setSpan(api.context.active(), span), () => oldHandler.call(this, ...params));",
115+
"filename": "[[FILENAME3]]",
116+
"function": "?",
135117
"in_app": false,
136-
"lineno": 57,
137-
"module": "@hapi.hapi.lib:toolkit",
118+
"lineno": 266,
119+
"module": "@opentelemetry.instrumentation-hapi.build.src:instrumentation",
138120
"post_context": [
139-
" }",
140-
"",
141-
" var response = await exports.timed(operation, options);",
142-
" }",
143-
" catch (err) {",
144-
" if (Bounce.isSystem(err)) {",
145-
" response = Boom.badImplementation(err);"
121+
" }",
122+
" catch (err) {",
123+
" span.recordException(err);",
124+
" span.setStatus({",
125+
" code: api.SpanStatusCode.ERROR,",
126+
" message: err.message,",
127+
" });"
146128
],
147129
"pre_context": [
148-
" if (bind) {",
149-
" operation = method.call(bind, request, h);",
150-
" }",
151-
" else if (options.args) {",
152-
" operation = method(request, h, ...options.args);",
153-
" }",
154-
" else {"
130+
" rpcMetadata.route = route.path;",
131+
" }",
132+
" const metadata = (0, utils_1.getRouteMetadata)(route, pluginName);",
133+
" const span = instrumentation.tracer.startSpan(metadata.name, {",
134+
" attributes: metadata.attributes,",
135+
" });",
136+
" try {"
155137
]
156138
},
157139
{
158-
"colno": 24,
159-
"context_line": " return __awaiter(this, void 0, void 0, function () {",
160-
"filename": "[[FILENAME3]]",
140+
"colno": 32,
141+
"context_line": " return __awaiter(this, void 0, void 0, function () {",
142+
"filename": "[[FILENAME4]]",
161143
"function": "handler",
162144
"in_app": true,
163-
"lineno": 72,
145+
"lineno": 98,
164146
"module": "app",
165147
"post_context": [
166-
" var exceptionId;",
167-
" return __generator(this, function (_a) {",
168-
" switch (_a.label) {",
169-
" case 0:",
170-
" exceptionId = Sentry.captureException(new Error('This is an error'));",
171-
" return [4 /*yield*/, Sentry.flush(2000)];",
172-
" case 1:"
148+
" var exceptionId;",
149+
" return __generator(this, function (_a) {",
150+
" switch (_a.label) {",
151+
" case 0:",
152+
" exceptionId = Sentry.captureException(new Error('This is an error'));",
153+
" return [4 /*yield*/, Sentry.flush(2000)];",
154+
" case 1:"
173155
],
174156
"pre_context": [
175-
" return { version: 'v1' };",
176-
" },",
177-
" });",
178-
" server.route({",
179-
" method: 'GET',",
180-
" path: '/test-error',",
181-
" handler: function (request, h) {"
157+
" return { version: 'v1' };",
158+
" },",
159+
" });",
160+
" server.route({",
161+
" method: 'GET',",
162+
" path: '/test-error',",
163+
" handler: function (request, h) {"
182164
]
183165
},
184166
{
185167
"colno": 12,
186168
"context_line": " return new (P || (P = Promise))(function (resolve, reject) {",
187-
"filename": "[[FILENAME3]]",
169+
"filename": "[[FILENAME4]]",
188170
"function": "__awaiter",
189171
"in_app": true,
190-
"lineno": 4,
172+
"lineno": 27,
191173
"module": "app",
192174
"post_context": [
193175
" function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }",
@@ -199,24 +181,28 @@
199181
"var __generator = (this && this.__generator) || function (thisArg, body) {"
200182
],
201183
"pre_context": [
202-
"\"use strict\";",
184+
" var result = {};",
185+
" if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);",
186+
" __setModuleDefault(result, mod);",
187+
" return result;",
188+
"};",
203189
"var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {",
204190
" function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }"
205191
]
206192
},
207193
{
208-
"filename": "[[FILENAME4]]",
194+
"filename": "[[FILENAME5]]",
209195
"function": "new Promise",
210196
"in_app": false,
211197
"module": "<anonymous>"
212198
},
213199
{
214200
"colno": 71,
215201
"context_line": " step((generator = generator.apply(thisArg, _arguments || [])).next());",
216-
"filename": "[[FILENAME3]]",
202+
"filename": "[[FILENAME4]]",
217203
"function": "?",
218204
"in_app": true,
219-
"lineno": 8,
205+
"lineno": 31,
220206
"module": "app",
221207
"post_context": [
222208
" });",
@@ -228,7 +214,7 @@
228214
" function step(op) {"
229215
],
230216
"pre_context": [
231-
"\"use strict\";",
217+
"};",
232218
"var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {",
233219
" function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }",
234220
" return new (P || (P = Promise))(function (resolve, reject) {",
@@ -240,10 +226,10 @@
240226
{
241227
"colno": 53,
242228
"context_line": " function verb(n) { return function (v) { return step([n, v]); }; }",
243-
"filename": "[[FILENAME3]]",
229+
"filename": "[[FILENAME4]]",
244230
"function": "Object.next",
245231
"in_app": true,
246-
"lineno": 14,
232+
"lineno": 37,
247233
"module": "app",
248234
"post_context": [
249235
" function step(op) {",
@@ -267,10 +253,10 @@
267253
{
268254
"colno": 23,
269255
"context_line": " op = body.call(thisArg, _);",
270-
"filename": "[[FILENAME3]]",
256+
"filename": "[[FILENAME4]]",
271257
"function": "step",
272258
"in_app": true,
273-
"lineno": 33,
259+
"lineno": 56,
274260
"module": "app",
275261
"post_context": [
276262
" } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }",
@@ -292,30 +278,30 @@
292278
]
293279
},
294280
{
295-
"colno": 71,
296-
"context_line": " exceptionId = Sentry.captureException(new Error('This is an error'));",
297-
"filename": "[[FILENAME3]]",
281+
"colno": 79,
282+
"context_line": " exceptionId = Sentry.captureException(new Error('This is an error'));",
283+
"filename": "[[FILENAME4]]",
298284
"function": "?",
299285
"in_app": true,
300-
"lineno": 77,
286+
"lineno": 103,
301287
"module": "app",
302288
"post_context": [
303-
" return [4 /*yield*/, Sentry.flush(2000)];",
304-
" case 1:",
305-
" _a.sent();",
306-
" return [2 /*return*/, { exceptionId: exceptionId }];",
307-
" }",
308-
" });",
309-
" });"
289+
" return [4 /*yield*/, Sentry.flush(2000)];",
290+
" case 1:",
291+
" _a.sent();",
292+
" return [2 /*return*/, { exceptionId: exceptionId }];",
293+
" }",
294+
" });",
295+
" });"
310296
],
311297
"pre_context": [
312-
" path: '/test-error',",
313-
" handler: function (request, h) {",
314-
" return __awaiter(this, void 0, void 0, function () {",
315-
" var exceptionId;",
316-
" return __generator(this, function (_a) {",
317-
" switch (_a.label) {",
318-
" case 0:"
298+
" path: '/test-error',",
299+
" handler: function (request, h) {",
300+
" return __awaiter(this, void 0, void 0, function () {",
301+
" var exceptionId;",
302+
" return __generator(this, function (_a) {",
303+
" switch (_a.label) {",
304+
" case 0:"
319305
]
320306
}
321307
]
@@ -397,10 +383,10 @@
397383
"packages": [
398384
{
399385
"name": "npm:@sentry/node",
400-
"version": "8.0.0-beta.6"
386+
"version": "8.0.0-rc.1"
401387
}
402388
],
403-
"version": "8.0.0-beta.6"
389+
"version": "8.0.0-rc.1"
404390
},
405391
"server_name": "D9M3PY4LQ7.local",
406392
"timestamp": "[[timestamp]]",

0 commit comments

Comments
 (0)