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

Socket.js option "sessionStorage" isn't optional. Opening a socket will fail if you don't define one. #5825

Closed
lylejantzi3rd opened this issue May 25, 2024 · 1 comment · Fixed by #5829

Comments

@lylejantzi3rd
Copy link

Environment

  • Elixir version (elixir -v): Node.js v20.12.2
  • Phoenix version (mix deps): 1.7.11
  • Operating system: Fedora 40

Actual behavior

Opening a socket results in an immediate error. Downgrading to 1.7.10 or providing sessionStorage as an option fixes it. This probably just needs some null checking.

import { Socket } from 'phoenix'
const socket = new Socket('wss://ladida.com/socket', params)

Results in the program terminating with the following error:

file:///home/username/code/ladida/node_modules/phoenix/priv/static/phoenix.mjs:1003
    this.sessionStore = opts.sessionStorage || global.sessionStorage;
                                                      ^
TypeError: Cannot read properties of undefined (reading 'sessionStorage')
    at new Socket (file:///home/username/code/ladida/node_modules/phoenix/priv/static/phoenix.mjs:1003:55)
    at file:///home/username/code/ladida/index.js:71:16
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.12.2

Expected behavior

Socket opens as expected

@lylejantzi3rd
Copy link
Author

Thanks!

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

Successfully merging a pull request may close this issue.

1 participant