Skip to content

THRIFT-4564: Correctly reset the transport in NodeJS - #3919

Open
KarboniteKream wants to merge 2 commits into
apache:masterfrom
KarboniteKream:fix/nodejs-transport-reset
Open

KarboniteKream wants to merge 2 commits into
apache:masterfrom
KarboniteKream:fix/nodejs-transport-reset

Conversation

@KarboniteKream

@KarboniteKream KarboniteKream commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Client: nodejs
Jira: THRIFT-4564

This PR is a follow-up to #1558, where the reset() method was added to TBufferedTransport. I discovered that the code was trying to call reset() on the protocol in the NodeJS branch, instead of on the transport, as intended. The missing .getTransport() was added, with an appropriate test.

The reset() method is also added to TFramedTransport, to unify the behavior.

@mergeable mergeable Bot added javascript Pull requests that update Javascript code nodejs typescript compiler labels Sep 21, 2026
@Jens-G

Jens-G commented Sep 21, 2026

Copy link
Copy Markdown
Member

Code review

No blocking issues found. Checked for bugs and CLAUDE.md compliance.

Two suggestions, below the bar for an issue but verified:

  • A small formality for when you next push: CONTRIBUTING.md asks for a Client: nodejs line below the subject of the commit message. At the moment it is only in the PR description.

thrift/CONTRIBUTING.md

Lines 22 to 27 in e8b37a0

1. Commit messages must follow this pattern for code changes (deviations will not be merged):
THRIFT-9999: [summary of fix, one line if possible]
Client: [language(s) affected, comma separated, for example: "cpp,erl,perl"]

  • The generated code now calls reset() on the transport if it has one. TBufferedTransport does, but TFramedTransport does not, so framed clients still send the half-written message in front of the next request: after testString(42) throws, the next testVoid() goes out as one 50-byte frame that starts with the 25 leftover bytes. This was the same before this PR. Adding a reset() to TFramedTransport that clears outBuffers and outCount fixes it; with that, the next frame contains only testVoid. That could go into this PR or into a follow-up.

}
f_service_ << indent() << "if (typeof " << outputVar << ".getTransport().reset === 'function') {" << '\n';
f_service_ << indent() << " " << outputVar << ".getTransport().reset();" << '\n';
f_service_ << indent() << "}" << '\n';
f_service_ << indent() << "throw e;" << '\n';

TBufferedTransport.prototype.reset = function () {
this.inBuf = Buffer.alloc(this.defaultReadBufferSize);
this.readCursor = 0;
this.writeCursor = 0;
this.outBuffers = [];
this.outCount = 0;
};

🤖 Generated with Claude Code

@KarboniteKream
KarboniteKream force-pushed the fix/nodejs-transport-reset branch from e8b37a0 to e9d233f Compare September 22, 2026 03:03

This branch has not been deployed

No deployments
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.

2 participants