I'm updating several thousand posts using this API over a WAN connection and received a lot of timeouts in the requests using the native superagent implementations. One way on solving this was to implement a "retry/timeout layer" in the application itself but then I found another package that's an extension of the superagent that is being used.
https://www.npmjs.com/package/superagent-retry-delay
In order to make use of this additional package only minor changes in the wpapi/lib/http-transport.js file is needed.
Added require('superagent-retry-delay')(agent); just after the row const agent = require( 'superagent' );
Changed all "requests" rows from: let request = _auth( agent.put( url ), .... to: let request = _auth( agent.get( url ).retry(5, 3600000, [401, 404]),.....
It works like a charm and I don't need to have logic in the application itself.
Is there any chance that this could be added to the native WP-API?
I'm updating several thousand posts using this API over a WAN connection and received a lot of timeouts in the requests using the native superagent implementations. One way on solving this was to implement a "retry/timeout layer" in the application itself but then I found another package that's an extension of the superagent that is being used. https://www.npmjs.com/package/superagent-retry-delay
In order to make use of this additional package only minor changes in the wpapi/lib/http-transport.js file is needed. Added require('superagent-retry-delay')(agent); just after the row const agent = require( 'superagent' ); Changed all "requests" rows from: let request = _auth( agent.put( url ), .... to: let request = _auth( agent.get( url ).retry(5, 3600000, [401, 404]),..... It works like a charm and I don't need to have logic in the application itself. Is there any chance that this could be added to the native WP-API?