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

.send() does not with without async/await. #141

Closed
paul-uz opened this issue Apr 11, 2024 · 2 comments
Closed

.send() does not with without async/await. #141

paul-uz opened this issue Apr 11, 2024 · 2 comments
Assignees

Comments

@paul-uz
Copy link

paul-uz commented Apr 11, 2024

Documentation leads you to believe that the .send() method can simply be called and data will be sent to your dashboard.

Using 0.13.2, this does not seem to be the case. I only get errors in my dashboard if I await the .send() method.

Are the docs out of date? Am I doing something wrong?

Here is my basic code, ran inside a Vitest test

    const foo = new Raygun.Client().init(
      {
        apiKey: '<MY_API_KEY>',
        reportColumnNumbers: true,
        reportUncaughtExceptions: true,
        batch: false,
        tags: ['vitest'],
      },
    );

    foo.send('test', {}, (res) => {
      console.log(res);
    });
@miquelbeltran
Copy link
Contributor

Are the docs out of date? Am I doing something wrong?

Going back to the original issue in the ticket.

The original send() would run asynchronously and spawn a request, so probably your test code finishes before even send() is done. I am honestly not sure why awaiting it does the trick here, since it's the callback what ensures that the error message was sent.

In the new send(), since it returns a Promise, you will be able to await the result and ensure that send() finished. Working on it on the PR #181

@miquelbeltran miquelbeltran moved this from In Progress to In Review in Raygun4Node board May 7, 2024
@sumitramanga sumitramanga moved this from In Review to Merged in Raygun4Node board May 8, 2024
@miquelbeltran
Copy link
Contributor

Resolved in 0.15.0-0

@miquelbeltran miquelbeltran moved this from Merged to Released in Raygun4Node board May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Released
Development

No branches or pull requests

3 participants