You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vite with build.minify on will minified the name of TRPCError so cause instanceof Error && cause.name === 'TRPCError' in getErrorFromUnknown will always get false.
So if I throw a TRPCError in procedure and handle it in onError option, the opts.error will be a TRPCError with code === 'INTERNAL_SERVER_ERROR' and the cause in my error.
This is the first issue, and next section might be second issue but...I just write it here.
After I patched getErrorFromUnknown with (cause instanceof Error && cause.name === 'TRPCError') || cause instance TRPCError (server_1.TRPCError in compiled outputs), I found out that the TRPCError from error.js and my code through import { TRPCError } from '@trpc/server' is not the same TRPCError...
It might be because the compiled outputs is in CommonJS which require the @trpc/server and I imported the @trpc/server with ESModule import, vite bundled both TRPCError of them, two different TRPCError-s.
Having an esm output might be helpful.
Dependencies:
@trpc/server: 10.33.0
trpc-chrome: 1.0.0
vite: 4.3.8
The text was updated successfully, but these errors were encountered:
Vite with
build.minify
on will minified the name of TRPCError socause instanceof Error && cause.name === 'TRPCError'
ingetErrorFromUnknown
will always getfalse
.So if I throw a TRPCError in procedure and handle it in
onError
option, theopts.error
will be a TRPCError withcode === 'INTERNAL_SERVER_ERROR'
and thecause
in my error.This is the first issue, and next section might be second issue but...I just write it here.
After I patched
getErrorFromUnknown
with(cause instanceof Error && cause.name === 'TRPCError') || cause instance TRPCError
(server_1.TRPCError
in compiled outputs), I found out that theTRPCError
fromerror.js
and my code throughimport { TRPCError } from '@trpc/server'
is not the same TRPCError...It might be because the compiled outputs is in CommonJS which
require
the@trpc/server
and I imported the@trpc/server
with ESModuleimport
, vite bundled both TRPCError of them, two different TRPCError-s.Having an esm output might be helpful.
Dependencies:
@trpc/server
:10.33.0
trpc-chrome
:1.0.0
vite
:4.3.8
The text was updated successfully, but these errors were encountered: