#147 global rate limiting by ip on public indexer endpoints fix#207
Conversation
…n-public-indexer-endpoints-FIX
- Complete the scripts block with distinct test / test:scripts / test:coverage / test:load keys (no duplicate keys, no missing commas). - Add resend, vitest and coverage devDependencies used by the rate-limiter tests. package-lock.json regenerated accordingly. - test-templates.js verified: node --check passes, single import block, single __filename / __dirname declarations, no SyntaxError.
|
@veloura-dev is attempting to deploy a commit to the david1984tk's projects Team on Vercel. A member of the Team first needs to authorize it. |
…n-public-indexer-endpoints-FIX
|
Thanks for flagging this. The Indexer Node.js CI failure was caused by duplicated/invalid code from a bad merge in the rate-limit implementation. Specifically, I cleaned up the duplicated merge code, rebased the branch on top of the latest remote branch, and verified the indexer test suite locally with: cd bimex-indexer Result: all indexer tests pass. The remaining Vercel check appears to be an authorization/protected-preview issue rather than a code failure. PLEASE REVIEW AND PING ME BACK |
|
@David1984TK PLEASE REVIEW |
…rom PR #207 - schema.sql: delete the duplicate rate-limit block (lines 50-200) that PR #207 inserted above the canonical '─── IP Rate Limiting ───' section. Both blocks used CREATE IF NOT EXISTS / CREATE OR REPLACE, so the second block always silently overwrote the first; any fix in the new block was a no-op in production. - schema.sql consume_rate_limit_bucket: fix retryAfter returning >= 1 even for allowed requests. Changed greatest(..., 1) to a CASE that returns 0 when count <= p_limit, matching the contract of acquire_sse_connection. - schema.sql acquire_sse_connection: replace pg_advisory_xact_lock(hashtext(p_key)) with pg_advisory_xact_lock(hashtext('rl_sse'), hashtext(p_key)) to avoid int4 hash collisions across unrelated SSE keys serializing each other. - schema.sql: remove WHAT-level comment line from the canonical block header. - package.json: fix test:scripts from "node --test scripts/test-scripts.js test/*.test.js" to "node scripts/test-scripts.js". The original mixed vitest-based test files (rateLimiter.test.js) into a node --test invocation that would see 0 tests and report a false pass; scripts/test-scripts.js also does not use the node:test API so --test was wrong for it too. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JfnhH2CghRyxav22rfM8bQ
…rom #207 (#208) - schema.sql: delete the duplicate rate-limit block (lines 50-200) that PR #207 inserted above the canonical '─── IP Rate Limiting ───' section. Both blocks used CREATE IF NOT EXISTS / CREATE OR REPLACE, so the second block always silently overwrote the first; any fix in the new block was a no-op in production. - schema.sql consume_rate_limit_bucket: fix retryAfter returning >= 1 even for allowed requests. Changed greatest(..., 1) to a CASE that returns 0 when count <= p_limit, matching the contract of acquire_sse_connection. - schema.sql acquire_sse_connection: replace pg_advisory_xact_lock(hashtext(p_key)) with pg_advisory_xact_lock(hashtext('rl_sse'), hashtext(p_key)) to avoid int4 hash collisions across unrelated SSE keys serializing each other. - schema.sql: remove WHAT-level comment line from the canonical block header. - package.json: fix test:scripts from "node --test scripts/test-scripts.js test/*.test.js" to "node scripts/test-scripts.js". The original mixed vitest-based test files (rateLimiter.test.js) into a node --test invocation that would see 0 tests and report a false pass; scripts/test-scripts.js also does not use the node:test API so --test was wrong for it too. Claude-Session: https://claude.ai/code/session_01JfnhH2CghRyxav22rfM8bQ Co-authored-by: Claude <noreply@anthropic.com>
Descripción
Este PR corrige dos archivos que rompían la instalación y la ejecución del indexer tras el merge de
mainen la rama del rate limiter (#147). Elpackage.jsonera JSON inválido (llave"test"duplicada y coma faltante), lo que hacía fallarnpm install; ytest-templates.jshabía quedado con imports duplicados y con__filename/__dirnamedeclarados dos veces, causandoSyntaxErroral ejecutarse.Closes #147
Cambios
bimex-indexer/package.json"test"duplicada y añadida la coma faltante que rompía el parseo JSON."test": "vitest run"— suite de vitest (la que usa CI)."test:scripts": "node --test scripts/test-scripts.js test/*.test.js"— runner nativo denode --test.test:coverageytest:loadsin cambios.bimex-indexer/package-lock.jsonnpm installpara reflejarresend,vitesty@vitest/coverage-v8correctamente resueltos.bimex-indexer/test-templates.jstmplBienvenida, tmplContribucion, tmplAprobacionHTML, tmplYieldDisponible,fs,pathyfileURLToPath.const __filenameyconst __dirname(causa raíz delSyntaxError: Identifier '__filename' has already been declared).node:(node:fs,node:path,node:url).'[https://...](https://...)') que había quedado en el valor deproyectoUrldentro demockData, reemplazado por una string plana.mockDataalineados con las variables reales de las plantillas (nombreProyecto,progreso,proyectoUrl), como los dejó el PR fix(test-templates): align mock data keys with template variable names #190.Verificación
node -e "require('./package.json')"→ JSON válido; los 8 scripts (start,api,reporte-mensual,reporte-mensual:dry-run,test,test:scripts,test:coverage,test:load) se cargan correctamente.npm install→ completa sin errores de parseo (155 paquetes instalados,package-lock.jsonactualizado).node --check bimex-indexer/test-templates.js→ sinSyntaxError.npm run test:runpasa sin errores (si aplica al frontend) — no aplica en este PR (cambios exclusivos del indexer).cargo testpasa sin errores (si aplica al contrato) — no aplica.npm run buildsin errores de compilación — no aplica (el indexer es Node ESM sin paso de build).npm run lintsin errores — no configurado enbimex-indexeractualmente.Notas para el revisor
mainelpackage.jsontenía tanto"test": "node --test ..."como"test": "vitest run". En JSON estricto la segunda llave silenciosamente sobreescribe a la primera, además de ser rechazado por varios linters. En vez de perder uno de los dos runners, se expusieron con nombres distintos (testytest:scripts). Si el equipo prefiere quedarse con un único runner, basta con eliminar el que sobre y hago el ajuste.package-lock.jsoncon muchas líneas cambiadas: son las sub-dependencias deresend,vitesty@vitest/coverage-v8que faltaban. Recomendado revisar sólopackage.jsona mano y aceptar el lock tal cual.mainen la rama (6d6dbae) para incorporar los cambios de#190. El force-push se hizo con--force-with-leasepara evitar sobrescribir trabajo ajeno.rateLimiter.js,schema.sql,test/rateLimiter.test.js,docs/api.md) no se toca y sigue siendo la revisada previamente por el maintainer.