Hapi: `route.method.toUpperCase is not a function` for routes registered with an array of methods
I maintainer di solito rispondono entro 1 giorno
@s1gr1d ci sta già lavorando.
Dal 19/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js, typescript
- Ambito
- backend, observability
Direzione di ricerca
Inizia da getRouteMetadata in packages/server-utils/src/integrations/hapi/hapi-utils.ts e dal percorso di wrapRouteHandler mostrato nello stack trace, quindi esegui la riproduzione dell'issue con node --import ./instrument.mjs server.mjs. Verifica come il handler avvolto riceve la richiesta risolta e come il suo metodo viene usato per il nome dello span e per http.request.method. Il lavoro è completo quando le route configurate tramite array non lanciano più errori, sia /single sia /multi restituiscono 200 con il ciclo di vita statico del trace e i metadati del metodo rimangono corretti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 8.8k
- Fork
- 1.9k
- Merge medio
- 1g 12h
- PR unite (30g)
- 598
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-javascript
-
node:http client span never ends when the response is destroyed without an error (res.destroy())Forse già presa @4ktLuffy l’ha presa 1 giorno fa. ApertaBug Node.js
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-javascript#25469 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Core Feature: Typescript Meta: Breaking
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-javascript#25286 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
getsentry/sentry-javascript#24860 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
getsentry/sentry-javascript#24200 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Cloudflare Workers javascript Tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-javascript#24051 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/sentry-javascript
Issue simili
-
area: app type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ExpidetGames/code-reviewer#585 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
module-federation/core#5205 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
LanternOps/breeze#9392 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
engine-rs P3 review-deferral wasm
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
maniator/verticopolis#1154 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno