Skip to content

THRIFT-6046: Limit struct read/write recursion depth in JavaScript library#3551

Draft
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:js-recursion-depth
Draft

THRIFT-6046: Limit struct read/write recursion depth in JavaScript library#3551
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:js-recursion-depth

Conversation

@Jens-G
Copy link
Copy Markdown
Member

@Jens-G Jens-G commented May 28, 2026

Summary

  • Adds incrementRecursionDepth() / decrementRecursionDepth() to Thrift.Protocol in lib/js/src/thrift.js
  • Same methods added to Node.js binary, compact and JSON protocol implementations in lib/nodejs/lib/thrift/
  • Limit is Thrift.DEFAULT_RECURSION_DEPTH (64); throws TProtocolException(DEPTH_LIMIT) when exceeded
  • JS generator emits calls around every generated read / write struct method

Test plan

  • lib/js/test/test-skip-depth.js — QUnit tests for allow/reject/restore
  • lib/nodejs/test/recursion_depth.test.js — Node.js tests via npm test

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

…ad/write

Client: js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jens-G Jens-G requested a review from emmenlau as a code owner May 28, 2026 11:46
@mergeable mergeable Bot added javascript Pull requests that update Javascript code nodejs typescript compiler labels May 28, 2026
@Jens-G Jens-G marked this pull request as draft May 28, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler javascript Pull requests that update Javascript code nodejs typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant