@@ -86,6 +86,7 @@ declare module 'fastify' {
8686
8787const HEALTH_ENDPOINT_ROUTES = [ '/health' , '/ready' ] as const ;
8888const FASTIFY_DUPLICATED_ROUTE_ERROR_CODE = 'FST_ERR_DUPLICATED_ROUTE' ;
89+ // TODO: Reassess the duplicated-route message format when upgrading Fastify.
8990
9091function setHeaders ( headers : ResponseResult [ 'headers' ] , res : FastifyReply ) {
9192 // eslint-disable-next-line @typescript-eslint/no-misused-promises -- fixing it with `void` just violates no-void
@@ -135,14 +136,15 @@ function applyFastifyConfigWithHealthEndpointMigrationHint(
135136 } catch ( error ) {
136137 const conflictingPath = enableHealthEndpoints ? conflictingHealthEndpointPath ( error ) : undefined ;
137138 if ( conflictingPath ) {
138- const originalMessage = error instanceof Error ? error . message : String ( error ) ;
139139 const message =
140140 `enableHealthEndpoints registers built-in GET ${ conflictingPath } , but a configureFastify callback ` +
141141 `already registered that route. Remove or rename the custom ${ conflictingPath } route when migrating ` +
142142 'to the built-in health endpoints. See docs/oss/building-features/node-renderer/health-checks.md.' ;
143143
144144 log . error ( { err : error , route : conflictingPath } , message ) ;
145- throw new Error ( `${ message } Original Fastify error: ${ originalMessage } ` ) ;
145+ const migrationError = new Error ( message ) as Error & { cause ?: unknown } ;
146+ migrationError . cause = error ;
147+ throw migrationError ;
146148 }
147149
148150 throw error ;
@@ -710,6 +712,10 @@ export default function run(config: Partial<Config>) {
710712 // Liveness: 200 whenever this process can answer — i.e. the event loop is
711713 // responsive. Intentionally checks no dependencies (no bundle, Rails, or
712714 // license state) so a transient dependency issue never restarts the pod.
715+ // Safe from a rate-limiting perspective (CodeQL js/missing-rate-limiting):
716+ // this is an internal renderer service not exposed to the internet, returns
717+ // a static status string, and exposes no sensitive runtime data.
718+ // lgtm[js/missing-rate-limiting]
713719 app . get ( '/health' , ( _req , res ) => {
714720 res . send ( { status : 'ok' } ) ;
715721 } ) ;
@@ -720,6 +726,9 @@ export default function run(config: Partial<Config>) {
720726 // bundles responds 410 to renders until the Rails client uploads one.
721727 // With workersCount > 1 the cluster module distributes probe connections
722728 // across workers, so a probe checks one worker per request.
729+ // Safe from a rate-limiting perspective (CodeQL js/missing-rate-limiting):
730+ // same rationale as /health; this returns only a static readiness status.
731+ // lgtm[js/missing-rate-limiting]
723732 app . get ( '/ready' , ( _req , res ) => {
724733 if ( hasAnyVMContext ( ) ) {
725734 res . send ( { status : 'ready' } ) ;
0 commit comments