hyper-fetch icon indicating copy to clipboard operation
hyper-fetch copied to clipboard

[Socket] getWebsocketAdapter/getSSEAdapter throws ReferenceError: window is not defined

Open AlexShRz opened this issue 9 months ago • 1 comments

Describe the bug getWebsocketAdapter and getSSEAdapter throws ReferenceError: window is not defined inside vitest env without jsdom.

To Reproduce

  1. Create new Socket()
  2. Try to run a random test using vitest/jest with it.

Expected behavior getWebsocketAdapter/getSSEAdapter should check environment before referencing the window variable. If current environment === webworker/service worker, etc., the window variable should not be referenced at all.

AlexShRz avatar Mar 31 '25 12:03 AlexShRz

I think it should be fine now 👍🏻

prc5 avatar Jun 26 '25 11:06 prc5