Hapi: `route.method.toUpperCase is not a function` for routes registered with an array of methods
Maintainer thường phản hồi trong vòng 1 ngày
@s1gr1d đang làm issue này rồi.
Từ ngày 19/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js, typescript
- Lĩnh vực
- backend, observability
Hướng nghiên cứu
Bắt đầu với getRouteMetadata trong packages/server-utils/src/integrations/hapi/hapi-utils.ts và đường dẫn wrapRouteHandler được hiển thị trong stack trace, sau đó chạy bản tái hiện trong issue với node --import ./instrument.mjs server.mjs. Kiểm tra xem handler được bọc nhận request đã phân giải như thế nào và phương thức của request được dùng ra sao cho tên span và http.request.method. Hoàn tất nghĩa là các route được cấu hình bằng array không còn ném lỗi, cả /single và /multi đều trả về 200 dưới vòng đời trace tĩnh và metadata của phương thức vẫn đúng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 8.8k
- Fork
- 1.9k
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 598
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-javascript
-
node:http client span never ends when the response is destroyed without an error (res.destroy())Có thể đã có người làm @4ktLuffy đã nhận hôm nay. Đang mởBug Node.js
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-javascript#25469 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Core Feature: Typescript Meta: Breaking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-javascript#25286 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
getsentry/sentry-javascript#24860 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
getsentry/sentry-javascript#24200 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Cloudflare Workers javascript Tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/sentry-javascript#24051 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/sentry-javascript
Issue tương tự
-
docs(api): openapi.yaml still documents gif-tools optimize colors as 2-256 instead of 2, 4, 16, 256Đang mởarea: backend documentation priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
snapotter-hq/SnapOtter#2919 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BUG: Uncaught MEMORY USAGE error on Redis < 4.0 causes keys table data load to fail entirelyĐang mởaccepted :+1: bug db/redis
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
beekeeper-studio/beekeeper-studio#4882 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
konflux-ci/konflux-ui#1630 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ahmedkhaleel2004/gitdiagram#233 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
simkimsia/netlify-axi#19 ·
Maintainer thường phản hồi trong vòng 1 ngày