Skip to content

Commit 730dcc2

Browse files
committed
Don't parse API requests before the request is completed
1 parent da910f8 commit 730dcc2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/model/http/exchange.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _ from 'lodash';
2-
import { observable, computed, action, runInAction } from 'mobx';
2+
import { observable, computed, action, runInAction, when } from 'mobx';
33

44
import {
55
HtkRequest,
@@ -327,6 +327,10 @@ export class HttpExchange extends HTKEventBase {
327327
const apiMetadata = await this._apiMetadataPromise;
328328

329329
if (apiMetadata) {
330+
// We load the spec, but we don't try to parse API requests until we've received
331+
// the whole thing (because e.g. JSON-RPC requests aren't parseable without the body)
332+
await when(() => this.isCompletedRequest());
333+
330334
try {
331335
if (apiMetadata.type === 'openapi') {
332336
return new OpenApiExchange(apiMetadata, this);

0 commit comments

Comments
 (0)