Skip to content

Commit

Permalink
fix 4 autobahn tests (#3254)
Browse files Browse the repository at this point in the history
use pull_request_target for autobahn workflow
  • Loading branch information
KhafraDev committed May 13, 2024
1 parent 388fe56 commit a52450b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/autobahn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Autobahn
on:
workflow_dispatch:

pull_request:
pull_request_target:
paths:
- '.github/workflows/autobahn.yml'
- 'lib/web/websocket/**'
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
run: npm run test:websocket:autobahn:report

- name: Generate Report for PR Comment
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request_target'
id: report-markdown
run: |
echo "comment<<nEOFn" >> $GITHUB_OUTPUT
Expand All @@ -64,7 +64,7 @@ jobs:
REPORTER: markdown

- name: Comment PR
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v2
with:
message: ${{ steps.report-markdown.outputs.comment }}
Expand Down
12 changes: 10 additions & 2 deletions lib/web/websocket/receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class ByteParser extends Writable {

if (isControlFrame(opcode)) {
const loop = this.parseControlFrame(callback, {
header: buffer,
opcode,
fragmented,
payloadLength
Expand All @@ -122,6 +123,7 @@ class ByteParser extends Writable {
}
} else if (isContinuationFrame(opcode)) {
const loop = this.parseContinuationFrame(callback, {
header: buffer,
fin,
fragmented,
payloadLength
Expand Down Expand Up @@ -297,7 +299,7 @@ class ByteParser extends Writable {
* Parses control frames.
* @param {Buffer} data
* @param {(err?: Error) => void} callback
* @param {{ opcode: number, fragmented: boolean, payloadLength: number }} info
* @param {{ opcode: number, fragmented: boolean, payloadLength: number, header: Buffer }} info
*/
parseControlFrame (callback, info) {
assert(!info.fragmented)
Expand All @@ -307,6 +309,9 @@ class ByteParser extends Writable {
failWebsocketConnection(this.ws, 'Payload length for control frame exceeded 125 bytes.')
return false
} else if (this.#byteOffset < info.payloadLength) {
this.#buffers.unshift(info.header)
this.#byteOffset += 2

callback()
return false
}
Expand Down Expand Up @@ -405,14 +410,17 @@ class ByteParser extends Writable {
* Parses continuation frames.
* @param {Buffer} data
* @param {(err?: Error) => void} callback
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number }} info
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number, header: Buffer }} info
*/
parseContinuationFrame (callback, info) {
// If we received a continuation frame before we started parsing another frame.
if (this.#info.opcode === undefined) {
failWebsocketConnection(this.ws, 'Received unexpected continuation frame.')
return false
} else if (this.#byteOffset < info.payloadLength) {
this.#buffers.unshift(info.header)
this.#byteOffset += 2

callback()
return false
}
Expand Down

0 comments on commit a52450b

Please sign in to comment.