Hapi: `route.method.toUpperCase is not a function` for routes registered with an array of methods
Mantenedores costumam responder em até 1 dia
@s1gr1d já está trabalhando nisso.
Desde 19/10/2026.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 88/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, node.js, typescript
- Domínio
- backend, observability
Direção de pesquisa
Comece por getRouteMetadata em packages/server-utils/src/integrations/hapi/hapi-utils.ts e pelo caminho de wrapRouteHandler mostrado no stack trace e execute a reprodução do issue com node --import ./instrument.mjs server.mjs. Verifique como o handler encapsulado recebe a requisição resolvida e como o método dela é usado para o nome do span e para http.request.method. Concluir significa que as rotas configuradas por array não lançam mais erros, que /single e /multi retornam 200 sob o ciclo de vida estático do trace e que os metadados do método permanecem corretos.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 8.8k
- Forks
- 1.9k
- Merge médio
- 1d 12h
- PRs com merge (30d)
- 598
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de getsentry/sentry-javascript
-
node:http client span never ends when the response is destroyed without an error (res.destroy())Talvez já em andamento @4ktLuffy assumiu há 1 dia. AbertaBug Node.js
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-javascript#25469 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Core Feature: Typescript Meta: Breaking
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
getsentry/sentry-javascript#25286 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
getsentry/sentry-javascript#24860 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
javascript
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
getsentry/sentry-javascript#24200 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Cloudflare Workers javascript Tests
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-javascript#24051 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de getsentry/sentry-javascript
Issues semelhantes
-
engine-rs P3 review-deferral wasm
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
maniator/verticopolis#1154 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
telerik/kendo-react#3861 ·
Mantenedores costumam responder em até 1 dia
-
[bug]: use-mobile.ts uses pixel logic, causing UI state de-sync with Tailwind CSS rem breakpointsAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100