]> git.codecow.com Git - nano25519.git/commitdiff
Adjust errors and logging.
authorChris Duncan <chris@zoso.dev>
Sat, 15 Aug 2026 10:08:10 +0000 (03:08 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 15 Aug 2026 10:08:10 +0000 (03:08 -0700)
src/lib/worker.ts

index 6d64a754346efcf91d3001d5f4df022377058108..1412f261491ee19fe57d8b481909cf5e9d51d6c2 100644 (file)
@@ -135,11 +135,11 @@ function init (): void {
                        worker.on('message', report)
                        worker.on('error', reset)
                }
-               console.log(`nano25519 initialized.`)
+               console.log(`nano25519/async initialized`)
                isWorkerReady = true
        } catch (err: any) {
                isWorkerReady = false
-               throw new Error('nano25519 initialization failed')
+               throw new Error('nano25519/async initialization failed')
        }
 }
 
@@ -163,8 +163,7 @@ function report (msg: { data: Record<string, unknown> }): void {
        const { result } = data
        console.log('received result from worker')
        if (typeof result !== 'boolean' && typeof result !== 'string' && !isBytes(result)) {
-               console.error(result)
-               return err('Invalid return type')
+               return err(`expected boolean, string, or bytes; received ${result?.constructor?.name ?? typeof result} '${result}`)
        }
        return ok(result)
 }
@@ -201,7 +200,6 @@ async function dispatch (data: Record<'action', Action> & Record<string, string
        console.log('sending data to worker')
        return new Promise((resolve, reject) => {
                tasks.set(id, [resolve, reject])
-               console.log('tasks', tasks)
                post(id, data, transfer)
        })
 }