Lloyd
02/17/2023, 8:04 PMChaika
03/15/2023, 10:25 PMrodbs
03/16/2023, 4:11 PMTypeError: globalThis.XMLHttpRequest is not a constructor
error.
But now it seems the sdk cannot connect to Azure's wss server.
I'm not sure why but I've read here that wrangler doesn't work with wss but only with ws. Is that right?jeremynevans
03/24/2023, 2:59 AMname = "renderer"
account_id = "16875cc7c5ec0ad968518988c731fcab"
workers_dev = false
compatibility_date = "2022-01-20"
main = "src/api/index.ts"
[vars]
ENVIRONMENT = "production"
[build]
command = "npm run build-worker"
kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]
[env.production]
vars = { ENVIRONMENT = "production" }
workers_dev = true
kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]
[env.staging]
vars = { ENVIRONMENT = "staging" }
kv_namespaces = [
{ binding = "FLOWS_KV", id = "00ca5df4edfa475e82a209d3de5e6d19", preview_id = "00ca5df4edfa475e82a209d3de5e6d19" }
]
Allright
03/30/2023, 3:29 AMcossinle
04/01/2023, 10:14 PM--local
argument. As soon as I switch it off it starts working again though, I have no idea what's going on
More details:
[mf:err] GET /: TypeError: Failed to parse URL from [object Object]
at new Request (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\undici\lib\fetch\request.js:81:15)
at new Request (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\miniflare\node_modules\@miniflare\core\src\standards\http.ts:455:13)
at EventTarget.dispatchFetch (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\miniflare\node_modules\@miniflare\core\src\index.ts:1077:51)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Server.<anonymous> (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\@miniflare\http-server\src\index.ts:291:20)
[mf:err] Cause: TypeError: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at new Request (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\undici\lib\fetch\request.js:79:21)
at new Request (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\miniflare\node_modules\@miniflare\core\src\standards\http.ts:455:13)
at EventTarget.dispatchFetch (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\miniflare\node_modules\@miniflare\core\src\index.ts:1077:51)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Server.<anonymous> (C:\Users\user\Documents\blogm-wrangler\blogm\node_modules\@miniflare\http-server\src\index.ts:291:20)
GET / 500 Internal Server Error (502.63ms)
sjnsnsjxne
04/09/2023, 12:09 PMzarg129
04/10/2023, 7:40 AMEli
04/10/2023, 9:19 AMtypescript
app.get('/events', async (c) => {
try {
const cacheUrl = c.req.url
const cache = caches.default
// Check if our response is already in the cache
let response = await cache.match(cacheUrl)
console.log('body', JSON.stringify(response?.body))
if (!response) {
const { email } = c.req.query()
const config = getConfig(c.env)
const events = await findEvents(email, config)
response = new Response(JSON.stringify({ data: events }))
response.headers.append('Cache-Control', 's-maxage=10')
c.executionCtx.waitUntil(cache.put(cacheUrl, response.clone()))
return c.json({
data: events
})
} else {
console.log(`cache hit for ${cacheUrl}`)
}
return response
} catch (err: Error | any) {
return c.json(
{
error: {
message: err.message
}
},
500
)
}
})
The logs are showing up as this with an empty body when hitting the cache.
json
{
"outcome": "ok",
"scriptName": "some script name",
"exceptions": [],
"logs": [
{
"message": [
"body",
"{}"
],
"level": "log",
"timestamp": 1681117743889
},
{
"message": [
"cache hit for https://someurl/events?email=someemail@email.com"
],
"level": "log",
"timestamp": 1681117743889
}
],
"eventTimestamp": 1681117743883,
"event": {
"request": {
"url": "some url",
"method": "GET",
"headers": {
"content-type": "application/json"
}
},
"response": {
"status": 500
}
},
"id": 27
}
Ssiswent
04/10/2023, 9:31 AMps
04/10/2023, 4:38 PMPato
04/10/2023, 5:39 PMShivansh Vij
04/10/2023, 9:55 PMTigersWay
04/11/2023, 8:15 AMJonathan Norris | DevCycle
04/11/2023, 3:49 PMsseLastModified
time that we use to compare against the Last-Modified
header of the CDN response. We are struggling to figure out the best way to invalidate the local data center cache from the worker without triggering many new requests to the global purge cache API.
The options we see are:
- Call the global purge cache API: https://developers.cloudflare.com/cache/how-to/purge-cache/#purge-by-single-file-by-url
- Will calling DELETE on the Worker Cache API invalidate the local cache for a fetch request to the CDN? (this wasn't clear in the docs): https://developers.cloudflare.com/workers/runtime-apis/cache/#delete
- Can this be accomplished by using the cf.cacheTtl = 0
property on our fetch request or some other property (we are an enterprise customer): https://developers.cloudflare.com/workers/runtime-apis/request/#requestinitcfproperties
Thanks for your help!
Jonathan Norrislokiwind
04/11/2023, 4:02 PM${ip}|${countryCode}
});
const init = {
method: "POST",
body: data
};
return fetch(url, init);
}
`F0rce
04/11/2023, 7:48 PMts
import { unstable_dev } from "wrangler";
import type { UnstableDevWorker } from "wrangler";
import { describe, expect, it, beforeAll, afterAll } from "vitest";
describe("API", () => {
let worker: UnstableDevWorker;
beforeAll(async () => {
worker = await unstable_dev("src/index.ts", {
config: "wrangler.toml",
experimental: { disableExperimentalWarning: true },
});
});
afterAll(async () => {
await worker.stop();
});
it("should return test user", async () => {
const resp = await worker.fetch("/api/v1/users/<id>", {
headers: { "X-Auth-Token": "shared-key" },
});
if (resp) {
const json = await resp.json();
expect(json).toMatchObject({
email: "user-mail",
});
}
});
});
StreoidVoid
04/12/2023, 10:32 AMonurrry
04/12/2023, 12:23 PMZetax
04/12/2023, 1:49 PMZetax
04/13/2023, 1:23 AMhttps://i.imgur.com/yQ7MxRA.pngā¾
Dio
04/13/2023, 7:07 AMZoltan
04/13/2023, 11:22 AMnew WebSocket()
using the unique ID from the message.
First I tried Service Bindings but that doesn't seem to support WebSockets yet.
Then I tried this new WebSocket()
connection but was getting 404 instead of 101 without hitting DO at all, after some trial and error and getting 1024 from a dummy fetch request, I found that CF doesn't allow connecting two Workers within the same account.
So then I opened another account and set up the DO there. This worked but I would need to duplicate half my infrastructure to this second account in order to have all the Service Bindings and KV stores. This is less than ideal.
Now, I'm trying to set up a simple WebSocket proxy on this 2nd account. ie.: Client -> Single WS (Account 1) -> Proxy (Account 2) -> DO WS (Account 1) -> Client
My understanding is that this should just work by CF magic passing around the request but the WS keeps disconnecting right after connecting without any errors. I tested a simple fetch on the proxy and that worked.
So I tried setting up a manual proxy where I listen for messages from the ws pair and pass it along to the DO, this seem to establish a persisting connection but nothing happens with the messaging. Not getting any errors just silently failing.
I would appreciate any insights or suggestions.Tino
04/13/2023, 2:06 PMlgraz
04/13/2023, 6:26 PMPeterMbanugo
04/13/2023, 8:04 PMbret_pat
04/13/2023, 9:30 PMuser6251
04/13/2023, 10:54 PMcf-ipcountry
and cf-ipcity
.
However, when I use the same approach to access cf-ray
, it's always null: request.headers.get('cf-ray')
Has this header been discontinued or do I have to enable it somewhere like the location headers? https://developers.cloudflare.com/fundamentals/get-started/reference/http-request-headers/#cf-rayxnslx
04/14/2023, 12:29 AMJulius
04/14/2023, 3:56 AM