Skip to content

Commit 6cae2fa

Browse files
committed
Resolve missing trap for failed deserialization in fetch transport
1 parent 8601c07 commit 6cae2fa

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

fetch/fetch-transport.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ const parseFetchResponse = ( response, wpreq ) => {
122122
return response.json().then( ( err ) => {
123123
// Throw the error object to permit proper error handling.
124124
throw err;
125+
}, () => {
126+
// JSON serialization failed; throw the underlying response.
127+
throw response;
125128
} );
126129
}
127130

tests/integration/error-states.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const SUCCESS = 'success';
55

66
describe.each( [
77
[ 'wpapi/superagent', require( '../../superagent' ) ],
8-
// [ 'wpapi/fetch', require( '../../fetch' ) ],
8+
[ 'wpapi/fetch', require( '../../fetch' ) ],
99
] )( '%s: error states:', ( transportName, WPAPI ) => {
1010

1111
it( 'invalid root endpoint causes a transport-level 404 error', () => {

0 commit comments

Comments
 (0)