Kynson
05/27/2023, 3:20 AMrattlesnake
05/28/2023, 12:52 AM"typescript": "^5.0.4"
"esbuild": "^0.17.19"
"miniflare": "^3.0.1"
"vitest": "^0.31.1"
"vitest-environment-miniflare": "^2.14.0"
"wrangler": "^2.20.0"
Scripts:
"test": "npm run build && NODE_OPTIONS=--experimental-vm-modules vitest"
"build": "esbuild --bundle --sourcemap --outdir=dist ./src/index.js"
In package.json:
"main": "./dist/index.js"
vitest.config.ts:
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
environment: "miniflare",
environmentOptions: {
modules: true,
scriptPath: "./dist/index.js",
durableObjects: {
TEST: "Test",
},
bindings: { TEST: "Test" },
},
},
});
Error:
Error: Class "Test" for Durable Object "TEST" not found
❯ DurableObjectsPlugin.reload node_modules/@miniflare/shared-test-environment/node_modules/@miniflare/durable-objects/src/plugin.ts:352:15
❯ MiniflareCore.#runAllReloads node_modules/@miniflare/shared-test-environment/node_modules/@miniflare/core/src/index.ts:705:24
❯ MiniflareCore.#reload node_modules/@miniflare/shared-test-environment/node_modules/@miniflare/core/src/index.ts:861:13
❯ MiniflareCore.getGlobalScope node_modules/@miniflare/shared-test-environment/node_modules/@miniflare/core/src/index.ts:1041:5
❯ Proxy.createMiniflareEnvironment node_modules/@miniflare/shared-test-environment/src/index.ts:79:25
❯ Object.setup node_modules/vitest-environment-miniflare/src/index.ts:79:33
❯ withEnv node_modules/vitest/dist/entry.js:182:15
❯ run node_modules/vitest/dist/entry.js:268:3
❯ run node_modules/vitest/dist/worker.js:69:5
❯ node_modules/tinypool/dist/esm/worker.js:109:20
Iscah
05/28/2023, 2:33 AMscript still in use as a consumer for a queue (Code: 10064)
And there's seemingly no queue in place.
Getting furious, though that doesn't help anything.kazu0617
05/28/2023, 6:40 AMCloudflare Workers Admin
as new account, but it can check audit log also.PencilNavigator
05/28/2023, 9:18 AMhttps://cdn.discordapp.com/attachments/1112308871327907922/1112308871537643630/b81205578d68fef7.png▾
https://cdn.discordapp.com/attachments/1112308871327907922/1112308871931895888/0d1b3495115002c3.png▾
https://cdn.discordapp.com/attachments/1112308871327907922/1112308873190199356/321689177dbc9ade.png▾
srnyx
05/28/2023, 4:45 PMjs
export default {
fetch(request) {
return new Response("Hello, World!");
}
}
I tried including a wrangler.toml
file too but that also didn't work:
toml
name = "srnyx-com"
main = "src/worker.js"
somoni
05/28/2023, 10:58 PMwrangler dev
✘ [ERROR] Could not resolve "shared"
src/worker.ts:11:22:
11 │ import {Greet01} from "shared"
╵ ~~~~~~~~
You can mark the path "shared" as external to exclude it from the bundle, which will remove this error.
✘ [ERROR] Build failed with 1 error:
src/worker.ts:11:22: ERROR: Could not resolve "shared"
o0th
07/19/2023, 6:58 AM[mf:err] TypeError: Illegal invocation
at Object.fetch (/path/src/index.js:59:5)
at __facade_modules_fetch__ (/tmp/tmp-778150-oye4YPdtwnN2/middleware-loader.entry.ts:46:16)
at __facade_invokeChain__ (/path/node_modules/wrangler/templates/middleware/common.ts:53:9)
at Object.next (/path/node_modules/wrangler/templates/middleware/common.ts:50:11)
at jsonError (/path/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
at __facade_invokeChain__ (/path/node_modules/wrangler/templates/middleware/common.ts:53:9)
at __facade_invoke__ (/path/node_modules/wrangler/templates/middleware/common.ts:63:9)
at Object.fetch (/tmp/tmp-778150-oye4YPdtwnN2/middleware-loader.entry.ts:114:11)
wrangler version 3.2.0 and 3.3.0. In this example I'm just running a resolve, running anything else the promise will run but the worker will die anyway
js
export default {
fetch: async (request, env, { waitUntil }) => {
waitUntil(Promise.resolve())
return new Response('hello')
}
}
am I doing something wrong?zeroblackalpha
07/28/2023, 6:10 AM@cloudflare/workers-wasi
and while it works locally using wrangler, I get a Promise will never complete.
error when actually deploying to cloudflare workers. I am using Wrangler 3.4.0 and Rust 1.71.0. I am building the WASI image using cargo-wasi in release mode, so wasm-opt is enabled.
worker.ts
import { WASI } from '@cloudflare/workers-wasi';
import demoWasm from '../../../target/wasm32-wasi/release/wasi_test.wasm';
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const stdout = new TransformStream();
const wasi = new WASI({
stdout: stdout.writable
});
const instance = new WebAssembly.Instance(demoWasm, {
wasi_snapshot_preview1: wasi.wasiImport
});
ctx.waitUntil(wasi.start(instance));
return new Response(stdout.readable);
}
};
main.rs
use image;
fn main() {
let image_bytes = include_bytes!("foster-lake.jpg");
let mut img = image::load_from_memory(image_bytes).expect("Failed to parse image");
let height = img.height();
println!("{height}");
}
The code seems to fail specifically on image::load_from_memory(image_bytes)
. The include_bytes
does work as the worker runtime correctly returns the image if I try to directly print out the bytes of the image to stdout. I don't expect to have hit any aborts or panics as the image is being loaded correctly and it decodes correctly locally. Are there known behavior differences between wrangler and the worker runtime for WASI?bonsaye
07/29/2023, 3:25 PMwrangler dev
In my worker script, I have console.log(request)
and in the terminal all I see is Request {
}
originalauthority
09/06/2023, 8:48 PMcfored
11/22/2023, 2:13 AMkittens-on-datura
12/02/2023, 6:13 PMthejedi3504
12/05/2023, 12:54 PMJacob Wright
12/13/2023, 5:38 PMunstable_dev(...)
before the beforeAll()
is finished executing. This is the same for my own projects.
> TypeError: fetch failed
> ❯ fetch node_modules/wrangler/wrangler-dist/cli.js:16838:17
> ❯ processTicksAndRejections node:internal/process/task_queues:95:5
> ❯ Object.fetch node_modules/wrangler/wrangler-dist/cli.js:151422:16
>
> Caused by: Error: connect ECONNREFUSED ::1:52557
> ❯ connect ECONNREFUSED ::1:52557
> ❯ TCPConnectWrap.afterConnect [as oncomplete] node:net:1495:16
Where/how should I report this?ajgeiss0702
12/13/2023, 5:52 PMsharp
package, however I realized this package is not compatable with workers.
I'm wanting to put it in an existing cron worker that puts the data into KV after. I already have it putting other data related to the image, so it makes sense to do it there too. I'm planning on just using google's OCR api since it seems to be the best.
Is there a similar one that does? The only thing I need to do is to darken the image so that OCR doesnt pick up on random details that I dont need (I just want it to read the big white text in the image)
Thank you in advancedanboyle8637
12/13/2023, 8:56 PMArtyum
12/16/2023, 12:28 PMjustinlesko
12/16/2023, 4:33 PMctx.waitUntil()
until the primary fetch()
has completed or canceled?ssokolow
12/16/2023, 8:47 PMCould not resolve "@cloudflare/pages-plugin-mailchannels"
error when I make a new push.
npmjs.com seems to indicate that @cloudflare/pages-plugin-mailchannels
still exists and has over 1,000 weekly downloads, which suggests it hasn't been renamed, but I have no experience with Cloudflare Workers and I find the distinction between using Workers and using Pages Functions hazy and confusing, so I don't know how to go about testing the "must be manually added as a dependency first" hypothesis with Git-based deploy (the docs just talk about Wrangler) and it being located in functions/_middleware.ts
.gutenight
12/17/2023, 2:46 AMSilabear
12/17/2023, 7:46 PMArnø
12/18/2023, 5:33 AMprodigy_anthill
12/18/2023, 7:18 AMxeon06
12/18/2023, 4:32 PMthecachier_17015
12/18/2023, 9:40 PMJanPrisma
12/19/2023, 2:50 AMpg
to connect to a remote database. As soon as I import and use pg
in one of my funtions though, I get errors like this during `npm run build`:
$ npm run build
> next-pg@0.1.0 build
> next build
▲ Next.js 14.0.4
Failed to compile.
./node_modules/pg-connection-string/index.js:76:69
Module not found: Can't resolve 'fs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/pg/lib/connection-parameters.js
./node_modules/pg/lib/client.js
./node_modules/pg/lib/index.js
./app/api/pg/route.js
...
How can I use pg
in a Next.js project that I want to deploy to Cloudflare Pages?plopix
12/19/2023, 6:22 AMcom.bo
12/19/2023, 9:43 AMmichael65610
12/19/2023, 3:43 PM