Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

fix(Request): forward Buffer & string payloads again#91

Open
pakerfeldt wants to merge 1 commit intoNRCHKB:devfrom
pakerfeldt:fix-request
Open

fix(Request): forward Buffer & string payloads again#91
pakerfeldt wants to merge 1 commit intoNRCHKB:devfrom
pakerfeldt:fix-request

Conversation

@pakerfeldt
Copy link
Copy Markdown

@pakerfeldt pakerfeldt commented May 6, 2025

What happened

PR #74 added a type‑safety guard to src/nodes/Request.ts:

const _send = (Result: UnifiResponse) => {
    self.send({
        payload: Result,
        inputMsg: msg,
    })
}
if (!Buffer.isBuffer(data) && typeof data !== 'string') {
    _send(data)
}

The guard works for JSON endpoints, but it silently drops every UniFi endpoint that returns raw bytes or plain text — most notably the Protect /snapshot thumbnails that are requested with responseType: 'arraybuffer'.
Since those thumbnails are delivered as Node Buffers, downstream flows never see them.

What this PR does

  • Restores the pre‑1.1 behaviour for binary and text payloads.
  • Keeps the stricter UnifiResponse typing for all JSON endpoints.
  • Collateral cleanup: Removes the console.log (moving the type printed into another debug log)

fixes #90

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant