You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2026/10/15 16:15:00 UTC
[jira] [Created] (THRIFT-6418) lib/js: TApplicationException has no Symbol.for("read") and Symbol.for("write") methods
Jens Geyer created THRIFT-6418:
----------------------------------
Summary: lib/js: TApplicationException has no Symbol.for("read") and Symbol.for("write") methods
Key: THRIFT-6418
URL: https://issues.apache.org/jira/browse/THRIFT-6418
Project: Thrift
Issue Type: Bug
Components: JavaScript - Library
Reporter: Jens Geyer
Since commit 5fc920dac ("Fix JS property/method collisions for fields enamed read/write", in 0.21.0 and later), the JavaScript generator keys the struct methods by symbol. The generated client reads an exception reply like this ({{t_js_generator.cc}}, line 2349 at f4d8e8c3f):
{code:javascript}
if (mtype == Thrift.MessageType.EXCEPTION) {
const x = new Thrift.TApplicationException();
x[Symbol.for("read")](input);
input.readMessageEnd();
...
}
{code}
The Node.js library gives its {{TApplicationException}} both symbol methods ({{lib/nodejs/lib/thrift/thrift.js}}, lines 88 and 123). The browser library {{lib/js/src/thrift.js}} does not. Its {{TApplicationException}} has only the plain {{read}} and {{write}} methods, and the file contains no {{Symbol}} at all. So a client generated for the browser, or for TypeScript against {{lib/js}}, throws
{noformat}
TypeError: x[Symbol.for(...)] is not a function
{noformat}
instead of returning the {{TApplicationException}} whenever the server answers with an exception, for example for an unknown method or an error in the handler. Generated processor code writes {{x[Symbol.for("write")](output)}} (line 1562), and it has the same gap wherever it runs against {{lib/js}}.
To check on v0.25.0, load {{lib/js/src/thrift.js}} in a Node.js {{vm}} context. {{typeof new Thrift.TApplicationException()[Symbol.for("read")]}} is {{"undefined"}}, and the call above throws the {{TypeError}}. v0.20.0 generated {{x.read(input)}}. v0.21.0 generates the symbol call, and its {{lib/js/src/thrift.js}} has no {{Symbol}} either.
THRIFT-6322 moved the browser tests to the symbol keys. That change covered the tests and the generated code, but not this class of the library.
Proposed change: add the two symbol methods to {{Thrift.TApplicationException}} in {{lib/js/src/thrift.js}}, delegating to the existing {{read}} and {{write}}. Add a test that reads an exception reply through a generated client.
_Drafted with AI assistance (Claude Opus 5.5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)