question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window not defined Error when using jsm.streams.getMessage("streamname", 1) syntax

See original GitHub issue

Hi! Thanks for your awesome work on NATS/Jetstream’s javascript client.

I encountered an error when I am using getMessage function. The code line that has an error is just the same as in the tutorial.

let sm = await jsm.streams.getMessage(stream, 1);

The error is as below:

ReferenceError: window is not defined
at StoredMsgImpl._parse (/node_modules/nats/lib/nats-base-client/jsstream_api.js:121:20)
at new StoredMsgImpl (/node_modules/nats/lib/nats-base-client/jsstream_api.js:111:45)
at StreamAPIImpl.<anonymous> (/node_modules/nats/lib/nats-base-client/jsstream_api.js:98:20)
at Generator.next (<anonymous>)
at fulfilled (/node_modules/nats/lib/nats-base-client/jsstream_api.js:19:58)
at processTicksAndRejections (node:internal/process/task_queues:94:5)

I felt the error quite confusing and does not understand what is happening behind it. Has anyone encountered same error and have some ideas? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aricartcommented, May 27, 2021

I’ll keep it open as a task…

0reactions
aricartcommented, Jun 2, 2021

@300LiterPropofol npm install nats@latest to get the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error `window not defined` in Node.js - Stack Overflow
Sawtaytoes has got it. I would run whatever code you have in componentDidMount() and surround it with: if (typeof(window) !== 'undefined') ...
Read more >
Accessing alternative data-streams of files on an NTFS volume
A pair of classes to encapsulate access to NTFS alternative data streams. ... include support for them with a special file syntax: Filename.ext:StreamName...
Read more >
JavaMail API Tutorial - Tutorialspoint
The JavaMail API provides a set of abstract classes defining objects ... This class represents an Internet email address using the syntax of....
Read more >
How to solve "window is not defined" errors in React and Next.js
js world, window is not defined, window is only available in browsers. There are three ways to solve that: 1. First solution: typeof....
Read more >
[Solved] ReferenceError : window is not defined - ItsJavaScript
Solution 1: Check whether browser or server-side execution · Solution 2: If error occurs while running on browser · How to use Global...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found