Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Deno 1.9.0 #144

Closed
edward653 opened this issue Apr 15, 2021 · 4 comments
Closed

Issue with Deno 1.9.0 #144

edward653 opened this issue Apr 15, 2021 · 4 comments

Comments

@edward653
Copy link

Upgraded to Deno 1.9.0 and alongside this, went from nats 1.0.0_rc4 to 1.0.2. Build fails with the following error:

error: TS2345 [ERROR]: Argument of type 'Conn' is not assignable to parameter of type 'Conn'.
Type 'Addr' is not assignable to type 'NetAddr'.
Type 'UnixAddr' is missing the following properties from type 'NetAddr': hostname, port
this.conn,
~~~~~~~~~
at https://deno.land/x/[email protected]/src/deno_transport.ts:144:7

I've not yet managed to dig into the cause, as yet. This doesn't seem to stem from my usage of the module.

@keawade
Copy link

keawade commented Apr 16, 2021

I've been seeing this issue as well trying to use the demo code.

Code to reproduce:

// import the connect function
import { connect } from "https://deno.land/x/[email protected]/src/mod.ts";

const servers = [
  {},
  { servers: ["demo.nats.io:4442", "demo.nats.io:4222"] },
  { servers: "demo.nats.io:4443" },
  { port: 4222 },
  { servers: "localhost" },
];
await servers.forEach(async (v) => {
  try {
    const nc = await connect(v);
    console.log(`connected to ${nc.getServer()}`);
    // this promise indicates the client closed
    const done = nc.closed();
    // do something with the connection

    // close the connection
    await nc.close();
    // check if the close was OK
    const err = await done;
    if (err) {
      console.log(`error closing:`, err);
    }
  } catch (err) {
    console.log(`error connecting to ${JSON.stringify(v)}`);
  }
});
~/Projects/deno-nats-test$ deno run --unstable --allow-net mod.ts
Check file:https:///home/keawade/Projects/deno-nats-test/mod.ts
error: TS2345 [ERROR]: Argument of type 'Conn<Addr>' is not assignable to parameter of type 'Conn<NetAddr>'.
  Type 'Addr' is not assignable to type 'NetAddr'.
    Type 'UnixAddr' is missing the following properties from type 'NetAddr': hostname, port
      this.conn,
      ~~~~~~~~~
    at https://deno.land/x/[email protected]/src/deno_transport.ts:144:7
~/Projects/deno-nats-test$ deno --version
deno 1.9.0 (release, x86_64-unknown-linux-gnu)
v8 9.1.269.5
typescript 4.2.2

Also confirmed that this code works with Deno 1.8.3:

~/Projects/deno-nats-test$ deno run --unstable --allow-net mod.ts
error connecting to {}
error connecting to {"port":4222,"servers":["127.0.0.1:4222"]}
error connecting to {"servers":["localhost"]}
connected to demo.nats.io:4222
connected to demo.nats.io:4443
~/Projects/deno-nats-test$ deno --version
deno 1.8.3 (release, x86_64-unknown-linux-gnu)
v8 9.0.257.3
typescript 4.2.2

@aricart
Copy link
Member

aricart commented Apr 16, 2021

Deno broke backwards compatibility with this denoland/deno#10200

@aricart
Copy link
Member

aricart commented Apr 16, 2021

Looks like they have relaxed the added generics, so until they release 1.9.1 you can downgrade - deno upgrade --version 1.8.3

@aricart
Copy link
Member

aricart commented May 11, 2021

version 1.0.4 is compatible with 1.9x and older. Newer versions of Deno should be happy with either or.

@aricart aricart closed this as completed May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants