Trouble with promise chaining and error handling in Effect Typescript library code

Hey ya'll ive done my due diligence for the past 4 hours and tried to use the docs and videos and whispers on the wind but something must be going over my head!

I have a promise, some processing on the result, then another promise that uses the result of the first. But for some reason everything I try I get runtime errors!

const eFormData = pipe(
  Effect.tryPromise(() => superValidate(request, effect(schema))), // <- superValidate is a promise that should never reject, it uses "valid" to define errors
  Effect.filterOrFail((f) => f.valid),
  Effect.andThen(f => supabase.auth.signUp(f.data)), // <- this one should be providing an error code and error value which seems fine, but if I add a tap(d => console.log("plz")) 
  Effect.filterOrFail((f) => !f.error)               // here it wont make it! I previously attempted to use another tryPromise + flatMap to no change
)

Effect.runPromise(eFormData)
  .catch(() => redirect(303, '/auth/error'))
  .then(() => redirect(303, '/'))


This is the error which to me feels like runPromise isnt actually waiting for the second promise to resolve
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Redirect>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}


Any advice at all is welcome! I thought I may have to do binds but that doesnt feel right
Was this page helpful?