-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
chore: hotfix v0.6.4 #67
Conversation
for await (const chunk of payload as ReadableStream) { | ||
contents += chunk.toString(); // Process each chunk of data | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix: consume the payload stream once, so it can be reused in the response and stored in the cache.
// Remove it so we can cache it properly | ||
request.headers['accept-encoding'] = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed since I don't know how to handle decompressing and re-compressing the reply afterwards.
Tested it on bff staging https://app.pulumi.com/cowprotocol/bff/staging/updates/178 Caching is working too (the important part) https://bff.barn.cow.fi/proxies/coingecko/simple/token_price/ethereum?contract_addresses=0x6B175474E89094C44Da98b954EedeAC495271d0F&vs_currencies=usd Will merge it, please post merge review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve, thanks for the fix :)
Summary
Changes based off of https://github.com/cowprotocol/bff/releases/tag/v0.6.3 which is the current prod version.
Pointing to the new branch
v0.6
.It fixes the issue with cached responses.
The requests are being cached, but the cached part is the stream, not the the actual payload.
Since the stream is consumed in the first reply, the subsequent tries in the cached version return nothing:
Note: in order to properly consume and cache the payload, I had to disable the compression, similar to what I did in my first attempt at this 55387a7