@@ -20,6 +20,8 @@ pub const IO = @import("tigerbeetle-io").IO;
2020const public = @import ("api.zig" );
2121const JSCallback = public .Callback ;
2222
23+ const log = std .log .scoped (.loop );
24+
2325fn report (comptime fmt : []const u8 , args : anytype ) void {
2426 const max_len = 200 ;
2527 var buf : [max_len ]u8 = undefined ;
@@ -113,7 +115,13 @@ pub const SingleThreaded = struct {
113115 defer ctx .loop .freeCbk (completion , ctx );
114116
115117 // TODO: return the error to the callback
116- result catch | err | @panic (@errorName (err ));
118+ result catch | err | {
119+ switch (err ) {
120+ error .Canceled = > {},
121+ else = > log .err ("timeout callback: {any}" , .{err }),
122+ }
123+ return ;
124+ };
117125
118126 const old_events_nb = ctx .loop .removeEvent ();
119127 if (builtin .is_test ) {
@@ -159,7 +167,10 @@ pub const SingleThreaded = struct {
159167 defer ctx .loop .freeCbk (completion , ctx );
160168
161169 // TODO: return the error to the callback
162- result catch | err | @panic (@errorName (err ));
170+ result catch | err | {
171+ log .err ("cancel callback: {any}" , .{err });
172+ return ;
173+ };
163174
164175 const old_events_nb = ctx .loop .removeEvent ();
165176 if (builtin .is_test ) {
@@ -180,7 +191,7 @@ pub const SingleThreaded = struct {
180191
181192 const completion = self .alloc .create (IO .Completion ) catch unreachable ;
182193 completion .* = undefined ;
183- const ctx = self .alloc .create (ContextTimeout ) catch unreachable ;
194+ const ctx = self .alloc .create (ContextCancel ) catch unreachable ;
184195 ctx .* = ContextCancel {
185196 .loop = self ,
186197 .js_cbk = js_cbk ,
0 commit comments