[ 
https://issues.apache.org/jira/browse/THRIFT-6331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6331.
--------------------------------
    Fix Version/s: 0.26.0
         Assignee: Jens Geyer
       Resolution: Fixed

> XHRConnection.read() cannot read a binary reply
> -----------------------------------------------
>
>                 Key: THRIFT-6331
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6331
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Library
>    Affects Versions: 0.24.0
>            Reporter: Jens Geyer
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.26.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Since THRIFT-4987, {{XHRConnection.flush()}} passes the replies of the binary 
> protocols to {{setRecvBuffer()}} as an {{ArrayBuffer}}. {{setRecvBuffer()}} 
> takes the size from {{length}}, which an {{ArrayBuffer}} does not have, so 
> {{recv_buf_sz}} and {{wpos}} end up {{undefined}}. {{read()}} then calls 
> {{substr()}} on the {{ArrayBuffer}}:
> {noformat}
> TypeError: this.recv_buf.substr is not a function
> {noformat}
> Decoding a reply is not affected, because it goes through {{Buffer.from()}} 
> and the transport's {{receiver()}}. Only code that calls {{read()}} directly 
> is.
> On master, {{read()}} fails for every reply for a second reason: it reads 
> from {{read_buf}}, which is never set. [PR 
> #3920|https://github.com/apache/thrift/pull/3920] fixes that. This ticket 
> covers the binary replies, which still fail after that fix.
> Proposed fix: size an {{ArrayBuffer}} by its {{byteLength}}, and let 
> {{read()}} return its bytes as a {{Buffer}}. The string replies of 
> {{TJSONProtocol}} are read as before.
> _Drafted with AI assistance (Claude Opus 5); reviewed and posted by Jens 
> Geyer._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to