Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont await to write cache in disk to respond to client #551

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/api",
"version": "6.45.24",
"version": "6.45.25-beta.0",
"description": "VTEX I/O API client",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient/middlewares/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
: data

const expiration = Date.now() + (maxAge - currentAge) * 1000
await storage.set(setKey, {
storage.set(setKey, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is still in Draft state, but just a suggestion: I feel like the span?.log call on line 210 below should only happen after the write finishes, so that we only log this on success and so that the trace shows the right timestamp for this event.

To do this we'll need to make sure that adding an event to a span after it's closed will work though. It might not be possible. Maybe this event won't make sense within that span anymore actually, since it's an event that happens afterwards, not tied to this span anymore. It'll just be background work now.

etag,
expiration,
response: {data: cacheableData, headers, status},
Expand Down
Loading