strongloop / strong-remoting

Communicate between objects in servers, mobile apps, and other servers.
www.strongloop.com
Other
105 stars 93 forks source link

support HTTP timeouts (and other request options) #307

Closed jbcpollak closed 6 years ago

jbcpollak commented 8 years ago

@richardpringle suggested I post a feature request here -

I would like to be able to control the request timeout from the client side, but it appears strong-remoting does not expose this functionality - It looks like the project doesn't allow the user to add fields to the request library's options object. That might be by design, but I think it would be useful to expose timeout and possibly a few other fields.

The lack of a timeout is causing me problems right now - the remote call doesn't timeout in a reasonable time, and my unit test actually times out before the call does, so I couldn't even see the root cause of the error, just that the test died. Now that I've figured that out, I'd like to set my timeout to be ~5 seconds (unit test timeout is 15 seconds), so that in the future this would be catchable, but I currently can't do that.

I think the usecases in production are obvious as well.

See https://github.com/strongloop/loopback-connector-remote/issues/48 for the downstream loopback-connector-remote feature request.

bajtos commented 7 years ago

+1

I am proposing to add a connector/datasource-level configuration to configure the timeout to use in the outgoing calls. @jbcpollak would you like to contribute this feature yourself? I am happy to guide you along the way.

richardpringle commented 7 years ago

@bajtos, still looking for a patch here? If so could use some guidance on how to test.

bajtos commented 7 years ago

@richardpringle sure. Here are existing tests where you can start looking:

As for testing timeouts, I think it makes most sense to add new tests to rest.browser.test.js, modify the configuration of RemoteObjects instance to specify a short timeout (~50ms), write a method that waits about twice as long (~100ms) before returning, and then verifying that an expected outcome happened.

bajtos commented 6 years ago

With the release of LoopBack 4.0 GA (see the announcement), this module has entered Active LTS mode and no longer accepts new features (see our LTS policy).