File tree Expand file tree Collapse file tree 3 files changed +34
-14
lines changed
Expand file tree Collapse file tree 3 files changed +34
-14
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,21 @@ import db from "~/database";
55import deleteBuildImage from "~/operations/deleteBuildImage" ;
66
77export async function destroy ( id : string , _ : FormData ) {
8- const serviceId = await db . transaction ( async tx => {
9- await removeImage ( id ) ;
10- const image = await deleteBuildImage ( tx , id ) ;
11- if ( ! image ) throw new Error ( "Invalid Build Image" ) ;
12- return image . serviceId ;
13- } ) ;
8+ let serviceId : string = "" ;
9+ try {
10+ serviceId = await db . transaction ( async tx => {
11+ await removeImage ( id ) ;
12+ const image = await deleteBuildImage ( tx , id ) ;
13+ if ( ! image ) throw new Error ( "Invalid Build Image" ) ;
14+ return image . serviceId ;
15+ } ) ;
16+ } catch ( error ) {
17+ if ( error && typeof error === "object" && "message" in error && error . message === "Transaction function cannot return a promise" ) {
18+ // do nothing. This is a known bug in Drizzle ORM
19+ // Check https://github.com/omermecitoglu/buttler/issues/40
20+ } else {
21+ throw error ;
22+ }
23+ }
1424 redirect ( `/services/${ serviceId } ` ) ;
1525}
Original file line number Diff line number Diff line change @@ -7,10 +7,19 @@ import createServiceLink from "~/operations/createServiceLink";
77import deleteNetwork from "~/operations/deleteNetwork" ;
88
99export async function create ( serviceId : string ) {
10- await db . transaction ( async tx => {
11- const { id : networkId } = await createNetwork ( tx , serviceId , "custom" ) ;
12- await createDockerNetwork ( networkId ) ;
13- } ) ;
10+ try {
11+ await db . transaction ( async tx => {
12+ const { id : networkId } = await createNetwork ( tx , serviceId , "custom" ) ;
13+ await createDockerNetwork ( networkId ) ;
14+ } ) ;
15+ } catch ( error ) {
16+ if ( error && typeof error === "object" && "message" in error && error . message === "Transaction function cannot return a promise" ) {
17+ // do nothing. This is a known bug in Drizzle ORM
18+ // Check https://github.com/omermecitoglu/buttler/issues/40
19+ } else {
20+ throw error ;
21+ }
22+ }
1423 redirect ( `/services/${ serviceId } /networks` ) ;
1524}
1625
Original file line number Diff line number Diff line change @@ -65,11 +65,12 @@ export async function create(formData: FormData) {
6565 }
6666 } ) ;
6767 } catch ( error ) {
68- console . error ( error ) ;
69- if ( error && typeof error === "object" && "message" in error ) {
70- console . log ( error . message ) ;
68+ if ( error && typeof error === "object" && "message" in error && error . message === "Transaction function cannot return a promise" ) {
69+ // do nothing. This is a known bug in Drizzle ORM
70+ // Check https://github.com/omermecitoglu/buttler/issues/40
71+ } else {
72+ throw error ;
7173 }
72- throw error ;
7374 }
7475 redirect ( "/services" ) ;
7576}
You can’t perform that action at this time.
0 commit comments