fix(files): await pull-mode stream readiness
This commit is contained in:
@@ -444,8 +444,12 @@ export function createFilesHttpClient(
|
||||
};
|
||||
return out;
|
||||
}
|
||||
// Streamed read — only supported when the queue drainer is wired.
|
||||
if (drainer === null) {
|
||||
// Streamed read — only supported when pull-mode was configured.
|
||||
// `drainer` is assigned asynchronously after the streams bridge has
|
||||
// subscribed, so checking it here races client construction. The
|
||||
// promise itself is the synchronous configuration signal; awaiting it
|
||||
// also guarantees the drainer has been installed by its `.then()`.
|
||||
if (streamsBridgePromise === null) {
|
||||
throw new InternalFileError(
|
||||
`http RPC client received a streamed read (size ${wire.size}) but is in inline-only mode. Pass { outboundQueueUrl, transferBaseUrl } when constructing the client to enable streamed reads.`,
|
||||
);
|
||||
@@ -507,8 +511,11 @@ export function createFilesHttpClient(
|
||||
);
|
||||
}
|
||||
|
||||
// Streamed write — requires the queue drainer + streams-bridge.
|
||||
if (drainer === null) {
|
||||
// Streamed write — requires pull-mode configuration. Do not inspect
|
||||
// `drainer` as a readiness flag: bridge registration is asynchronous,
|
||||
// and an immediate large write must wait for it instead of being
|
||||
// misclassified as an inline-only client.
|
||||
if (streamsBridgePromise === null) {
|
||||
throw new ConflictError(
|
||||
`http RPC client supports inline writes only (≤ ${INLINE_THRESHOLD} bytes). The supplied input was promoted to streams (size ${decision.size ?? 'unknown'}). Pass { outboundQueueUrl, transferBaseUrl } to enable streamed writes.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user