Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node - hapi
SDK Version
11.5.0; also present in 11.8.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
instrument.mjs:
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: 'https://[email protected]/1',
tracesSampleRate: 1,
traceLifecycle: 'static',
});server.mjs:
import Hapi from '@hapi/hapi';
const server = Hapi.server({ port: 0 });
server.route({ method: ['GET', 'POST'], path: '/multi', handler: () => 'ok' });
server.route({ method: 'GET', path: '/single', handler: () => 'ok' });
await server.start();
for (const path of ['/single', '/multi']) {
const res = await fetch(server.info.uri + path);
console.log(path, res.status);
}
await server.stop();Run node --import ./instrument.mjs server.mjs
Expected Result
Both requests return 200.
Actual Result
/single returns 200; /multi returns 500:
TypeError: route.method.toUpperCase is not a function
at getRouteMetadata (@sentry/server-utils/src/integrations/hapi/hapi-utils.ts:132:73)
at <anonymous> (@sentry/server-utils/src/integrations/hapi/hapi-utils.ts:202:24)
at exports.Manager.execute (@hapi/hapi/lib/toolkit.js:57:29)
at internals.handler (@hapi/hapi/lib/handler.js:46:48)
...
With the default traceLifecycle ('stream'), both return 200.
Additional Context
Hapi accepts method as a string or an array of strings. wrapRouteHandler passes the route config given to server.route() to getRouteMetadata. For non-streamed spans, that builds the span name as `${route.method.toUpperCase()} ${route.path}`, which assumes a string. The streamed-span branch only uses route.path, which is why the default lifecycle is unaffected. Either way, the array also ends up in the http.request.method attribute.
A possible fix: inside the wrapped handler, read the method from the request (request.method, which Hapi has already resolved to one lowercase method) rather than from the route config.
Priority
No response
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Oct 18, 2026
JS-3953
s1gr1d commentedon Oct 20, 2026
Hi, thanks for writing in. I added a PR to fix this: #25527
fix(node): Use the request method for Hapi routes with multiple metho…
github-actions commentedon Oct 28, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #25527, which was included in the 11.10.0 release.