Skip to content

Dev/uno#7

Merged
Nadhila-dot merged 3 commits intomainfrom
dev/uno
Mar 28, 2026
Merged

Dev/uno#7
Nadhila-dot merged 3 commits intomainfrom
dev/uno

Conversation

@Nadhila-dot
Copy link
Copy Markdown
Collaborator

@Nadhila-dot Nadhila-dot commented Mar 28, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Route-level response caching with configurable TTL, max entries, and cache key variation
    • Per-route request validation for body, query parameters, and path parameters
    • Automatic worker thread scaling based on available CPU cores
    • I/O operation timeouts for improved reliability
  • Security

    • Hardened request parsing to prevent request smuggling attacks
    • Enhanced path traversal detection
  • Performance

    • Per-worker connection limiting to prevent resource exhaustion
  • Documentation

    • Added comprehensive API documentation and type annotations
    • Updated performance testing guidelines

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

Warning

Rate limit exceeded

@Nadhila-dot has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 57 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 25 minutes and 57 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbfa2f3b-7a39-4787-bf17-9580bb339e17

📥 Commits

Reviewing files that changed from the base of the PR and between e1008db and 066dec7.

⛔ Files ignored due to path filters (1)
  • rust-native/build.log is excluded by !**/*.log
📒 Files selected for processing (10)
  • readme.md
  • rust-native/src/lib.rs
  • rust-native/src/manifest.rs
  • rust-native/src/router.rs
  • src/bridge.js
  • src/http-server.config.js
  • src/index.js
  • src/native.js
  • src/opt/runtime.js
  • src/validate.js
📝 Walkthrough

Walkthrough

The PR introduces per-route response caching with configurable TTL and cache-key variance (query/path/header based), alongside significant Rust runtime improvements: automatic worker thread sizing, per-worker connection limits, I/O timeouts (read/write), request smuggling hardening, and expanded HTTP error reason phrases. JavaScript-side changes include path normalization utilities, refactored query parsing, JSON error handling, and response fingerprinting via FNV-1a hashing.

Changes

Cohort / File(s) Summary
Documentation & Configuration
readme.md, src/http-server.config.js, src/native.js
Updated README performance claims; added JSDoc type definitions and normalizeHttpServerConfig() helper; documented native module loading behavior.
Rust Runtime Enhancements
rust-native/src/lib.rs
Enabled automatic worker thread sizing via available_parallelism(), added per-worker connection limiting (4096 max), implemented I/O timeouts (first header read, idle keep-alive, body chunk, response write), request smuggling hardening via Transfer-Encoding/Content-Length validation, expanded HTTP reason phrase map, and refactored error response building.
Routing & Cache Manifest
rust-native/src/manifest.rs, rust-native/src/router.rs
Added RouteInput.cache field with CacheConfigInput and CacheVaryInput structs; implemented RouteCacheConfig, CacheVaryKey enum, thread-local LRU RouteCache, and get_cached_response/insert_cached_response APIs; added cache key interpolation based on query/path/header vary sources; expanded status reason map.
Request/Response Bridge
src/bridge.js
Added JSDoc annotations for all exported APIs; rewrote query parsing to avoid URLSearchParams with manual splitting and decodeURIComponent fallback; wrapped req.json() in try/catch with custom SyntaxError; reset additional validation fields (validatedBody, validatedQuery, validatedParams) during object pooling.
Route Registration & Path Handling
src/index.js
Added normalizePathPrefix() and normalizeRoutePath() utilities with leading / enforcement; changed pooled response state reset to use Object.create(null) instead of key deletion; enhanced createMethodRegistrar() to support optional options parameter for cache config; integrated cache metadata into manifest during listen().
Runtime Optimization
src/opt/runtime.js
Replaced JSON.stringify + base64 response fingerprinting with FNV-1a hash-based buildResponseKey() returning compact ${hash}:${body.length}:${headerCount} format; added fnv1aString() and fnv1aBytes() helpers; expanded JSDoc documentation for internal functions.
Validation Middleware
src/validate.js
Updated JSDoc to clarify support for .parse(), .safeParse(), .validate() schema methods; refined error handling documentation; core control flow unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Handler as HTTP Handler<br/>(Rust)
    participant Cache as RouteCache<br/>(Thread-local LRU)
    participant Dispatch as JS Dispatch<br/>(via Bridge)
    participant Router as Router/Vary<br/>Key Builder

    Client->>Handler: POST /api/data
    Handler->>Router: Build cache key<br/>(vary by query/header)
    Router->>Handler: Cache key hash
    Handler->>Cache: get_cached_response(route_id, key)
    alt Cache Hit
        Cache-->>Handler: CacheEntry (Bytes)
        Handler->>Client: 200 + cached response
    else Cache Miss
        Handler->>Dispatch: Dispatch request to JS
        Dispatch->>Dispatch: Execute handler logic
        Dispatch-->>Handler: Dynamic response (Bytes)
        Handler->>Cache: insert_cached_response<br/>(route_id, key, entry, ttl)
        Cache-->>Cache: Store w/ expiry
        Handler->>Client: 200 + dynamic response
    end
Loading
sequenceDiagram
    participant Client
    participant Handler as HTTP Handler<br/>(Rust)
    participant Reader as Read Timeout<br/>Manager

    Client->>Handler: TCP connection
    Handler->>Reader: timeout(HEADER_READ, <br/>read_http_header)
    alt First Request
        Reader->>Handler: header within<br/>TIMEOUT_FIRST_HEADER_READ
    else Subsequent Request
        Reader->>Handler: header within<br/>TIMEOUT_IDLE_KEEP_ALIVE
    end
    alt Timeout
        Reader-->>Handler: Timeout error
        Handler->>Client: (close, no response)
    else Success
        Handler->>Handler: Parse headers<br/>(check Transfer-Encoding)
        Handler->>Handler: Drain body with<br/>TIMEOUT_BODY_CHUNK
        Handler->>Handler: Write response w/<br/>TIMEOUT_WRITE
        Handler->>Client: Response bytes
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hops through the cache with glee,
Timeouts guard each boundary,
Worker threads now count themselves,
Response keys hash FNV\-1a wealth,
Vary-by queries, headers in flight—
A faster web, done oh-so-right!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/uno

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Nadhila-dot Nadhila-dot merged commit a72d3e1 into main Mar 28, 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

Development

Successfully merging this pull request may close these issues.

1 participant