Skip to content
Myr

Fix race condition issue with `.json()` (#731)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by GitHub · parent a87d9e9 · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:source/core/Ky.ts+5 added-4 removed
110 unmodified lines
111 if (response.status === 204) {112 return '';113 }114115 const arrayBuffer = await response.clone().arrayBuffer();116 const responseSize = arrayBuffer.byteLength;117 if (responseSize === 0) {115 const text = await response.text();116 if (text === '') {117 return '';118 }119120 if (options.parseJson) {122 return options.parseJson(await response.text());121 return options.parseJson(text);122 }123124 return JSON.parse(text);125 }126127 return response[type]();128 };
225 unmodified lines