Skip to content

Conversation

benduran
Copy link
Contributor

Partially-resolves PFI-101

Summary

As the title suggests, there was a bug in the lazer Websocket client, which was built and intended to built use isomorphically across browser and server-side JavaScript environments.

However, the current implementation made assumptions that the Buffer class would be available in all environments, when it is not something that exists in the browser.

As such, this PR adds the following:

  • Initial conversion of all non-string WebSocket frames to an ArrayBuffer
  • Then, pass the created ArrayBuffer into newly-created IsomorphicBuffer.from() function
    This allows all existing logic to remain in place, minimizing changes or needing to create approximations of functions but against the ArrayBuffer class.

Rationale

This feels like the least risky way to fix the issue with isomorphism. This PR does not address the auth token being provided in the QueryString at WSS open time. This will occur in another PR, as that will have some business logic changes that change how connections are created and destroyed.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

see videos, below

Working in Node

CleanShot.2025-10-15.at.16.12.29.mp4

Working in the browser

CleanShot.2025-10-15.at.16.40.22.mp4

@benduran benduran added the bug Something isn't working label Oct 15, 2025
@linear
Copy link

linear bot commented Oct 15, 2025

@vercel
Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Oct 17, 2025 10:57am
component-library Ready Ready Preview Comment Oct 17, 2025 10:57am
developer-hub Ready Ready Preview Comment Oct 17, 2025 10:57am
proposals Ready Ready Preview Comment Oct 17, 2025 10:57am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
entropy-explorer Skipped Skipped Oct 17, 2025 10:57am
insights Skipped Skipped Oct 17, 2025 10:57am
staking Skipped Skipped Oct 17, 2025 10:57am

@benduran benduran requested a review from cprussin October 15, 2025 15:45
@vercel vercel bot temporarily deployed to Preview – developer-hub October 15, 2025 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library October 15, 2025 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer October 15, 2025 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview – insights October 15, 2025 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview – staking October 15, 2025 15:47 Inactive
Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good! I have minor nits / points to consider but nothing that I would block merging on, feel free to consider / address any or disregard as you see fit.

@benduran
Copy link
Contributor Author

update: given the branch on which this PR was crafted is fairly old, I'm not confident in my knowledge of the changeset context (it's my 4th day, after all 😂 ), I'll be taking some of the feedback given on this PR and crafting the changes on the latest code available on main. I will update this branch and re-tag folks for a final review later today

@benduran benduran force-pushed the bduran/lazer-js-sdk/browser-support branch from f15c41b to 84190a4 Compare October 16, 2025 10:23
@benduran
Copy link
Contributor Author

@cprussin @tejasbadadare would appreciate another pass over this, as I've updated this branch and implement changes with, hopefully, a bit better organization (like the new IsomorphicBuffer.fromWebsocketData() function), to hopefully simplify things.

Responded to most PR feedback left in the prior iteration 🤞

@vercel vercel bot temporarily deployed to Preview – insights October 16, 2025 11:31 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer October 16, 2025 11:31 Inactive
@benduran
Copy link
Contributor Author

@cprussin @tejasbadadare responded to all PR feedback. I'm going to let this simmer until you all log on for the day, as I haven't released an NPM package here yet and want to be sure I do it in a manner that you all are expecting. I see the Readme has steps outlined, so I'll run with those and ping if I have questions

@benduran
Copy link
Contributor Author

requires a re-review from you all (thanks for your patience here)

Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@benduran benduran merged commit 487ae1e into main Oct 20, 2025
12 checks passed
@benduran benduran deleted the bduran/lazer-js-sdk/browser-support branch October 20, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants