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

ErrorOptions is not defined in errors.ts #177

Closed
csokviktor opened this issue Dec 12, 2024 · 8 comments
Closed

ErrorOptions is not defined in errors.ts #177

csokviktor opened this issue Dec 12, 2024 · 8 comments

Comments

@csokviktor
Copy link

Observed behavior

ErrorOptions is not defined in errors.ts and package is unusable.

image

Expected behavior

ErrorOptions is defined in errors.ts and package is usable.

Server and client version

@nats-io/nats-core: "3.0.0-48"

Host environment

No response

Steps to reproduce

No response

@aricart
Copy link
Member

aricart commented Jan 2, 2025

This is a built-in type on es2022, perhaps bump your typescript version to something like:

  "compilerOptions": {
    "target": "esnext",
...

@aricart aricart closed this as completed Jan 2, 2025
@csokviktor
Copy link
Author

csokviktor commented Jan 17, 2025

We are using es2022 and the error still occurs. It is not possible in our use case to use esnext as we are using this package in an Angular application.

@aricart
Copy link
Member

aricart commented Jan 18, 2025

what is your angular version

@aricart aricart reopened this Jan 18, 2025
@csokviktor
Copy link
Author

Thanks for reopening the issue. We are running Angular 18.

@aricart
Copy link
Member

aricart commented Jan 19, 2025

works for me on 19.

@aricart
Copy link
Member

aricart commented Jan 19, 2025

Note quite sure what you are doing, but verified it works on 18/19.

Here's on 18
Image

modified generated app.component.ts (ng new ...)

import { Component } from "@angular/core";
import { RouterOutlet } from "@angular/router";
import { nuid, wsconnect, nanos } from "@nats-io/nats-core";
import { jetstreamManager, AckPolicy, jetstream } from "@nats-io/jetstream";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [RouterOutlet],
  templateUrl: "./app.component.html",
  styleUrl: "./app.component.css",
})
export class AppComponent {
  title = "ang-18";

  ngOnInit() {
    (async () => {
      const nc = await wsconnect({ servers: "demo.nats.io:8443" });
      console.log("connected to", nc.getServer());
      const subj = nuid.next();
      const sub = nc.subscribe(`${subj}.*`, {
        callback: (_, msg) => {
          console.log(`sub: ${msg.subject}`);
        },
      });

      let counter = 0;
      setInterval(() => {
        nc.publish(`${subj}.${counter++}`);
      }, 500);

      const jsm = await jetstreamManager(nc);
      await jsm.streams.add({
        name: subj,
        subjects: [`${subj}.*`],
        max_age: nanos(5_000),
        max_msgs: 20
      });

      const ci = await jsm.consumers.add(subj, {
        ack_policy: AckPolicy.Explicit,
      });

      const js = jetstream(nc);
      const c = js.consumers.getConsumerFromInfo(ci);
      const iter = await c.consume();
      for await(const m of iter) {
        console.log(m.seq, m.subject);
      }
    })();
  }
}
/p/t/ang-18 (main) [SIGINT]> npm ls
[email protected] /private/tmp/ang-18
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @nats-io/[email protected]
├── @nats-io/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

@aricart
Copy link
Member

aricart commented Jan 19, 2025

Feel free to re-open, but simple example works for me.

@aricart aricart closed this as completed Jan 19, 2025
@aricart
Copy link
Member

aricart commented Jan 19, 2025

One thing that comes to mind is that possibly you are using the jsr libs, so you are effectively re-building the library - just use the node library (npm install @nats-io/nats-core) - core has support for websockets

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

2 participants