GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — websocket: don't use pooled buffer in mask pool by tsctx · Pull Request #3357 · nodejs/undici

Conversation

@tsctx

@tsctx tsctx commented Jun 22, 2024

Copy link
Copy Markdown
Member

@mcollina

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tsctx
websocket: don't use pooled buffer in mask pool
97b5ba2
@tsctx
tsctx requested a review from mcollina June 22, 2024 07:08
tsctx
tsctx commented Jun 22, 2024
View reviewed changes
Comment thread lib/web/websocket/frame.js
if (bufIdx === BUFFER_SIZE) {
bufIdx = 0
crypto.randomFillSync((buffer ??= Buffer.allocUnsafe(BUFFER_SIZE)), 0, BUFFER_SIZE)
crypto.randomFillSync((buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE)), 0, BUFFER_SIZE)

@tsctx tsctx Jun 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No problem, but with the current code, I have some concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Jun 22, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don't see them, unless we acess buffer.buffer anywhere

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tsctx tsctx Jun 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If they access it, they can rewrite the mask, right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tsctx tsctx Jun 22, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

example:

import { WebSocket } from './index.js'

Buffer.poolSize = 16386 * 4

// any echo server url
const u = new WebSocket('ws://localhost:3000')

u.onmessage = (data) => {
  // The mask can be rewritten here.
  new Uint8Array(Buffer.allocUnsafe(1).buffer).fill(0)
  u.send('Hi')
}
u.onopen = () => {
  u.send('Hi')
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ronag
ronag approved these changes Jun 22, 2024
View reviewed changes
KhafraDev
KhafraDev approved these changes Jun 22, 2024
View reviewed changes

@KhafraDev KhafraDev left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is it possible to add a test?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tsctx

tsctx commented Jun 22, 2024

Copy link
Copy Markdown
Member Author

Unfortunately, I can write a test, but this can't catch using pooled buffer completely.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KhafraDev

KhafraDev commented Jun 22, 2024

Copy link
Copy Markdown
Member

better something than nothing

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tsctx
add test
abc6323
@tsctx

tsctx commented Jun 22, 2024

Copy link
Copy Markdown
Member Author

test was placed incorrectly. this can catch it until now!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tsctx added 2 commits June 23, 2024 06:15
@tsctx
fixup
cae53bc
@tsctx
fixup
071528e
ronag
ronag approved these changes Jun 23, 2024
View reviewed changes
@ronag
ronag merged commit 27b2589 into nodejs:main Jun 23, 2024
@tsctx
tsctx deleted the websocket/donot-use-pooled-buffer branch June 23, 2024 07:06
ronag added a commit to nxtedition/undici that referenced this pull request Jun 25, 2024
@ronag
Merge remote-tracking branch 'upstream/main'
1aa10e3
* upstream/main:
  fix: use explicit flag for when use has interacted with stream (nodejs#3361)
  refactor: simplify signal handling (nodejs#3362)
  fix: consider bytes read when dumping (nodejs#3360)
  websocket: don't use pooled buffer in mask pool (nodejs#3357)
  Revert "fix: post request signal (nodejs#3354)" (nodejs#3359)
  fix: post request signal (nodejs#3354)
  build(deps): bump node from `075a5cc` to `9af472b` in /build (nodejs#3355)
@github-actions github-actions Bot mentioned this pull request Dec 3, 2024
[Release] v7.1.0 #3922
Merged
This was referenced Dec 16, 2024
[Release] v7.1.1 #3952
Closed
[Release] v7.2.0 #3962
Merged
@github-actions github-actions Bot mentioned this pull request Mar 12, 2025
[Release] v6.21.2 #4092
Closed
@github-actions github-actions Bot mentioned this pull request May 12, 2025
[Release] v6.21.3 #4211
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ronag ronag ronag approved these changes
@mcollina mcollina Awaiting requested review from mcollina
+1 more reviewer
@KhafraDev KhafraDev KhafraDev approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tsctx @KhafraDev @mcollina @ronag
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.