-
Notifications
You must be signed in to change notification settings - Fork 280
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
Support withCache
in debug-network for workerd
#1438
Conversation
}; | ||
|
||
function getHeader(key: string, request?: CrossRuntimeRequest) { |
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.
Isn't request
just type Request
?
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.
In Oxygen yes but in Node environments they will be passing IncomingMessage
(import type {IncomingMessage} from 'node:http'), I think? And the headers
there doesn't have a get
function, you just read like in an object.
I assume Bun and Deno probably have similar APIs for requests, either Web-like or Node-like, but maybe with different type name.
@@ -13,7 +13,8 @@ export default { | |||
const cache = await caches.open('my-cms'); | |||
const withCache = createWithCache({ | |||
cache, | |||
waitUntil: executionContext.waitUntil, | |||
waitUntil: executionContext.waitUntil.bind(executionContext), |
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.
Are we losing this
context without the bind
?
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.
Yes, we already use .bind
in all our templates so I just updated it here as well.
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.
If we embrace supporting cross platform request
objects, and have the generic getHeader
function, I wonder if we could also get rid of getStorefrontHeaders
, and just pass in a request
object to createStorefrontClient
.
Actually, I just remembered there's another constraint in This is also kind of true for the |
We can't use
AsyncLocalStorage
in Workerd to pass downrequest-id
and other information. This PR adds new parameters tocreateWithCache
to manually pass the required information down so that we can show calls towithCache
in/debug-network
.Currently passing
request
but we can change it toheaders
or something else. Waiting on another conversation before deciding the final API.