error codes are not preserved

This issue has been tracked since 2023-03-16.

Describe the bug

I am emitting an error from connect-go like so:

connectgo.NewError(connectgo.CodeFailedPrecondition, errors.New("Service is disabled."))

The server is emitting the error correctly but when the transport handler calls connectFromReason, the instanceof check is failing and a new error is being created with the default code Internal.

See debugger output below. The error should have been returned on line 98 but instead the instanceof check fails and the code continues to create a new error.

Screenshot from 2023-03-16 12-35-57

Here are more details about the error:
Screenshot from 2023-03-16 12-41-55

I did some research and from what I can tell this should ensure that we can correctly determine what the class is but it seems not to be working as expected:

Object.setPrototypeOf(this, new.target.prototype);

Environment (please complete the following information):

npm list

├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
├── @parcel/[email protected]
├── @primer/[email protected]
├── @primer/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
  • Node.js version: v18.14.2
  • Browser and version: Google Chrome 111.0.5563.64
danielhochman wrote this answer on 2023-03-19

I just noticed a new release and tried the new versions but still not working.

├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
├── @bufbuild/[email protected]
smaye81 wrote this answer on 2023-03-20

Hi @danielhochman. Could you provide a few more details about your environment? For example:

  • It looks like you're using Parcel as your bundler, correct? Are you using any other Parcel / Babel presets? It seems like you are not, but just wanted to confim.
  • Can you share your tsconfig.json file?
  • Also can you share how you are building your application? i.e. is it something like npx tsc && parcel build src/index.html

Trying to track this error down and have been unable to recreate it locally thus far.

danielhochman wrote this answer on 2023-03-20

tsconfig.json

{
  "compilerOptions": {
    "jsx": "react",
    "target":"es2022",
    "moduleResolution": "node",
    "types": ["react/next", "react-dom/next"]
  },
  "include": ["source/*.ts*"],
  "exclude": ["node_modules/**/*"]
}

.parcelrc

{
	"extends": "@parcel/config-webextension"
}

build command (this is a browser extension)

parcel build source/manifest.json
More Details About Repo
Owner Name bufbuild
Repo Name connect-es
Full Name bufbuild/connect-es
Language TypeScript
Created Date 2022-02-16
Updated Date 2023-03-24
Star Count 852
Watcher Count 20
Fork Count 33
Issue Count 17

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date