Skip to content

fix: correct receiveFrom call signature in Parent constructor#101

Open
blahah wants to merge 1 commit intoholepunchto:mainfrom
blahah:fix/parent-receivefrom-signature
Open

fix: correct receiveFrom call signature in Parent constructor#101
blahah wants to merge 1 commit intoholepunchto:mainfrom
blahah:fix/parent-receivefrom-signature

Conversation

@blahah
Copy link
Copy Markdown

@blahah blahah commented Dec 1, 2025

Summary

Fix ui.app.parent throwing TypeError: The "listener" argument must be of type function when accessed from within a ui.View.

Problem

The Parent class constructor was passing two arguments to receiveFrom():

ipc.receiveFrom(id, (...args) => {
  this.emit('message', ...args)
})

But receiveFrom() only accepts one argument (the listener function), so id was being treated as the listener, causing:

TypeError: The "listener" argument must be of type function. Received undefined
    at checkListener (events:140:11)
    at Readable.once (events:634:3)
    at get parent (pear-electron/lib/index.js:163:24)

Solution

Remove the erroneous id argument to align with how GuiCtrl#rxtx() correctly calls receiveFrom():

ipc.receiveFrom((...args) => {
  this.emit('message', ...args)
})

Test plan

  • Verified ui.app.parent no longer throws when accessed from a ui.View
  • Parent-child messaging works correctly after the fix

Fixes #98

🤖 Generated with Claude Code

The Parent class constructor was passing two arguments to receiveFrom():
  ipc.receiveFrom(id, (...args) => { ... })

But receiveFrom() only accepts one argument (the listener function).
This caused the id to be treated as the listener, which then threw:
  TypeError: The "listener" argument must be of type function

This fix aligns with how GuiCtrl#rxtx() correctly calls receiveFrom():
  ipc.receiveFrom((...args) => this.emit('message', ...args))

Fixes holepunchto#98

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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 this pull request may close these issues.

ui.app.parent getter throws TypeError when accessed from ui.View

1 participant