MCPcopy Create free account
hub / github.com/Effect-TS/effect / onMessage

Function onMessage

packages/sql/sqlite-wasm/src/SqliteClient.ts:332–354  ·  view source on GitHub ↗
(event: any)

Source from the content-addressed store, hash-verified

330 yield* Scope.addFinalizer(scope, Effect.sync(() => postMessage(["close"])))
331
332 const onMessage = (event: any) => {
333 const [id, error, results] = event.data
334 if (id === "ready") {
335 Deferred.doneUnsafe(readyDeferred, Exit.void)
336 return
337 } else if (id === "update_hook") {
338 reactivity.invalidateUnsafe({ [error]: [results] })
339 return
340 } else {
341 const resume = pending.get(id)
342 if (!resume) return
343 pending.delete(id)
344 if (error) {
345 resume(
346 Exit.fail(
347 new SqlError({ reason: classifyError(error, "Failed to execute statement", "execute") })
348 )
349 )
350 } else {
351 resume(Exit.succeed(results))
352 }
353 }
354 }
355 port.addEventListener("message", onMessage)
356 if ("start" in port) {
357 port.start()

Callers

nothing calls this directly

Calls 6

classifyErrorFunction · 0.70
getMethod · 0.65
deleteMethod · 0.65
failMethod · 0.65
resumeFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected