Pretty specific attack vector, hackers intercepting an authed users session? What is your use case e
Pretty specific attack vector, hackers intercepting an authed users session? What is your use case exactly?
then if a hacker were to spam my service with a bunch of GET /documents/XXXXX calls trying to find a valid document, that every one of those invalid GETs would create a new DO that wouldn't be deleted because the SQLite database would be created simply by the act of accessing it, even if it returns a 404. Is that right?My own solution to that is to only run the migrations when they are needed.
Specifically for Durable Object classes with SQLite storage backend, KV operations which were previously asynchronous (for example, get, put, delete, deleteAll, list) are synchronous, even though they return promises. These methods will have completed their operations before they return the promise.
runDurableObjectAlarm() return true or a similar value?while (true) what about while (ran)? Declare ran as true before the first runawait to be consistent with the API that you need to await a Promise. The underlying behavior doesn't change.await of a promise will be more confused, rather than having to read all the DO docs to figure out that it doesn't matter.When deleting a migration using npx wrangler deploy --delete-class <ClassName>, you may encounter this error: "Cannot apply --delete-class migration to class <ClassName> without also removing the binding that references it". You should remove the corresponding binding under [durable_objects] in wrangler.toml before attempting to apply --delete-class again.[[migrations]]
tag = "v1"
new_classes = ["Job"]
[[migrations]]
tag = "v2"
new_classes = ["FirebaseCache"]
[[migrations]]
tag = "v3"
deleted_classes = ["FirebaseCache"]
new_classes = ["RPCResource"]await this.#_config.doStorage.put<number>(this.#_lastMigrationIDKeyName(), this.#_lastMigrationMonotonicId);let ran = false;
ran = await runDurableObjectAlarm(stub) // ran = true
ran = await runDurableObjectAlarm(stub) // ran = true
ran = await runDurableObjectAlarm(stub) // ran = true
ran = await runDurableObjectAlarm(stub) // ran = true
ran = await runDurableObjectAlarm(stub) // ran = falsewhile (true) {
let ran = await runDurableObjectAlarm(stub)
if (!ran) {
break
};
}import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"
import { unstable_dev } from "wrangler"
import type { UnstableDevWorker } from "wrangler"
describe("Worker", () => {
let worker: UnstableDevWorker
beforeAll(async () => {
worker = await unstable_dev("src/worker/index.ts", {
experimental: { disableExperimentalWarning: true },
})
})
afterAll(async () => {
await worker.stop()
})
it("should deny request for invalid paths", async () => {
const cases = {
failures: ["/", "/foo", "/foo/", "/%2F"],
}
for (const path of cases.failures) {
const resp = await worker.fetch(`http://localhost:3000${path}`)
console.log(resp)
expect(resp.status).toBe(404)
}
})
})