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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 BUG: .run() throws D1 Error in cloud #441
Comments
According to the docs, |
It may or may not fail, it's completely up to the API design, at least should be consistent locally and in the cloud |
Agreed |
Hi鈥攖hanks for reporting this! That's definitely a local/remote behaviour mismatch that we should fix. In the meantime, you can often get more helpful error message by checking export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
await env.DB.exec(
"create table if not exists users (name text, email text);"
);
try {
await env.DB.prepare(
"insert into users (name, email) values (?, ?) returning *"
)
.bind("a", "b")
.run();
} catch (e) {
return new Response(e.cause);
}
return new Response("Hello World!");
},
}; |
Previously, Miniflare had its own implementations of `BetaDatabase` and `Statement`. These were subtly different to the implementations in the D1 Wrangler shim D1JS, causing behaviour mismatches. This change switches the implementation to use the shim, with Miniflare implementing the underlying D1 HTTP API instead. We'll need to do this anyway when adding D1 support to Miniflare 3 using `workerd`. Specific changes: - Throw when calling `D1PreparedStatement#run()` with statements that return data, closes #441 - Fix response envelope format, closes #442 and cloudflare/workers-sdk#2504 - Fix binding/return of `BLOB`-typed values, closes wrangler2#2527 - Fix `D1Database#raw()` return, closes cloudflare/workers-sdk#2238 (already fixed in #474) - Add support for `D1Database#dump()` - Run `D1Database#{batch,exec}()` statements in implicit transaction - Only run first statement when calling `D1PreparedStatement#{first,run,all,raw}()`
Previously, Miniflare had its own implementations of `BetaDatabase` and `Statement`. These were subtly different to the implementations in the D1 Wrangler shim D1JS, causing behaviour mismatches. This change switches the implementation to use the shim, with Miniflare implementing the underlying D1 HTTP API instead. We'll need to do this anyway when adding D1 support to Miniflare 3 using `workerd`. Specific changes: - Throw when calling `D1PreparedStatement#run()` with statements that return data, closes #441 - Fix response envelope format, closes #442 and cloudflare/workers-sdk#2504 - Fix binding/return of `BLOB`-typed values, closes wrangler2#2527 - Fix `D1Database#raw()` return, closes cloudflare/workers-sdk#2238 (already fixed in #474) - Add support for `D1Database#dump()` - Run `D1Database#{batch,exec}()` statements in implicit transaction - Only run first statement when calling `D1PreparedStatement#{first,run,all,raw}()`
What version of
Wrangler
are you using?2.4.2
What operating system are you using?
Mac
Describe the Bug
throws
Exception
in cloudThese three below work as expected in cloud
All four requests do work as expected locally
The text was updated successfully, but these errors were encountered: