Skip to content

feat: add RateLimitParser, metadata validator, memory profiler, and enricher cache - #792

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
Ebuka321:feat/throttle-validator-profiler-cache
Aug 30, 2026
Merged

feat: add RateLimitParser, metadata validator, memory profiler, and enricher cache#792
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
Ebuka321:feat/throttle-validator-profiler-cache

Conversation

@Ebuka321

Copy link
Copy Markdown
Contributor

Changes

Closes #746 — Parse Retry-After header with fractional seconds

  • Created src/throttle/RateLimitParser.ts with parseRetryAfter(value: string): number | null
  • Uses parseFloat for fractional seconds (e.g., "1.5" → 1500 ms)
  • Handles HTTP-date format values converted to ms delay from now
  • Returns null for unparseable values instead of NaN

Closes #742 — Enforce maximum key length for custom metadata fields

  • Created src/validators/invoiceMetadataValidator.ts
  • Exports MAX_METADATA_KEY_LENGTH = 64
  • validateMetadataKeys() rejects keys longer than 64 characters with descriptive errors
  • Validates both top-level and nested custom keys

Closes #739 — Add heap snapshot export to memoryProfiler

  • Created src/memoryProfiler.ts with MemoryProfiler class
  • exportHeapSnapshot(outputPath: string): Promise<string> writes .heapsnapshot files via v8.writeHeapSnapshot
  • Throws ProfilerNotInitializedError if profiler not initialized
  • Includes init(), snapshot(), getSnapshots(), reset() methods

Closes #737 — Cache enriched metadata with configurable TTL

  • Created src/enricher.ts with EnricherCache<T> class
  • getOrFetch(key, fetch) caches results with configurable ttlMs (default 60,000 ms)
  • clearCache() empties the cache on demand
  • Uses Date.now() for expiry checking — no external cache libraries

Verification

  • npm run lint passes
  • npm run test (32 tests) passes
  • New test file test/modules.test.ts adds 30 tests covering all 4 modules
  • Total: 62 tests passing

…nricher cache

Closes Stellar-split#746: Parse Retry-After header with fractional seconds using parseFloat
Closes Stellar-split#742: Enforce max key length (64 chars) for custom metadata fields
Closes Stellar-split#739: Add V8 heap snapshot export to memoryProfiler
Closes Stellar-split#737: Cache enriched metadata with configurable TTL in enricher
@Ebuka321
Ebuka321 force-pushed the feat/throttle-validator-profiler-cache branch from 54c032f to a955f4d Compare August 29, 2026 17:07
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Ebuka321 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit 271dbab into Stellar-split:main Aug 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants