Getting tags associated with a Hibernatable WebSocket

Also, random question but if we support this.state.getTags(webSocket) for hibernatable websockets, would y'all want it to throw an error if you give it a non-hibernatable websocket? Or would you just want it to give you an empty array?
M
milan•127d ago
If you're in a webSocketX() handler then the websocket you're given through the function arg is obviously hibernatable. If you get your websockets from this.state.getWebSockets(), you also know they're hibernatable. However, if you're saving them in some property on your DO I figure you could lose track if you use both regular and hibernatable ws in a single namespace. Just want to see if any of y'all have an opinion 🙂
Z
zegevlier•127d ago
I think it makes more sense for it to throw than to return an empty list. The tag list for the non-hibernatable websocket isn't empty, it just doesn't exist. This would also create a way to differentiate between the two (if it throws it's a non-hibernatable, if it doesn't throw it's hibrenatable), which could be useful.
M
milan•126d ago
Agreed, thanks for your input!
W
WillTolmie•124d ago
Isn’t using exceptions for flow control in normal execution an ant pattern? I’d have thought just returning null be more natural?
M
milan•111d ago
Sorry, didn't see this! I suppose the broader point here is that if your script ever does throw this error, it's an indication that you're doing something wrong (and it's fixable). You shouldn't be giving state.getTags() a regular websocket because it's essentially the wrong argument type. If we were just to return null, developers might assume that's the same as "no tags", and then continue on without realizing they're intermingling separate APIs.
Want results from more Discord servers?
Add your server
More Posts
React Native + Worker + KVHello, I'm currently making a React Native app and I'm trying to get/send data to my KVs in cloudflaReferenceError: crypto is not definedI have a javascript file which makes use of crypto. This file is used by both my Cloudflare Pages FuDNS blacklistingHey guys, not sure how to conact support for this issue, but a cloudfare IP range has been blacklistStorage TechnologiesWe're partly porting over functionality that uses MongoDB for JSON document storage, so I'm looking Tried subscribing for R2 but getting error with card detailsHi, after trying with multiple Visa, Master and Amex cards to subscribe R2 service but still gettingAn itty-router-openapi app stopped working with TypeError: o3.replace is not a functionAfter a week of developing a small REST API which was working beautifully, suddenly this error just Hi guys. instantlog does not show cookiesWhat could this be related to?Issues with Zero Trust Device Posture still not solvedHello, the status says that the problems have been solved but still does not work for me. Does anyonif i have an array of primary keys, howif i have an array of primary keys, how do i search using IN? will this work? or do i need to formatWasm problem with Sveltekit, Cloudflare Pages and Resvg.I'm trying to implement dynamic opengraph images, and so far the most promising solution has been saWhich object holds environment variables (Nuxt)I just configured & deployed a nuxt app to be deployed to cloudflare pages. Environment variables arLogin issues (yes, another one)...• Every 2FA code I enter is invalid—I have tried on multiple machines with 2 different auth apps tha