There are concerns that when sending an occurrence, the write of the POST request payload can be blocked, blocking the caller. This is specifically about the request write not completing, not about any delay or timeout related to the response, which is already async.
While the http response completes async, the request is performed on the caller's thread. There are concerns that the caller could be blocked in some cases.
This PR uses a zero setTimeout to get off the caller's tick before making the request. This PR also updates all tests that relied on the request being synchronous. (Typically tests that inspect the request.)
Notes:
This PR adheres to this project's es5 syntax.
The execution is kept synchronous until the payload is fully constructed. Making these paths async would cause an undesired change in behavior where objects such as custom data would change value before being evaluated for the payload.
If the subsequent network write blocks the event loop, that may still lead to a perf impact, but that is outside the scope of this PR.
Type of change
[x] Bug fix (non-breaking change that fixes an issue)
Description of the change
There are concerns that when sending an occurrence, the write of the POST request payload can be blocked, blocking the caller. This is specifically about the request write not completing, not about any delay or timeout related to the response, which is already async.
While the http response completes async, the request is performed on the caller's thread. There are concerns that the caller could be blocked in some cases.
This PR uses a zero setTimeout to get off the caller's tick before making the request. This PR also updates all tests that relied on the request being synchronous. (Typically tests that inspect the request.)
Notes: This PR adheres to this project's es5 syntax.
The execution is kept synchronous until the payload is fully constructed. Making these paths async would cause an undesired change in behavior where objects such as custom data would change value before being evaluated for the payload.
If the subsequent network write blocks the event loop, that may still lead to a perf impact, but that is outside the scope of this PR.
Type of change
Related issues
Fixes: https://app.shortcut.com/rollbar/story/112245 Fixes: https://github.com/rollbar/rollbar.js/issues/1036
Development
Code review