Real Time Phoenix Errata P47: missing {} on channel creation causes blocking error

As of 2020-11-25 The syntax of channel.push(...) should be updated to include a second parameter.
As written the book states on page 47:

channel.push("ping")
    .receive(...)

This causes an error that precedes and prevents joining the channel in addition to preventing the reception of any messages back from the server:
image

A slight modification allows success:

channel.push("ping", {})
    .receive(...)

This error is likely due to a contract change in the Phoenix channel library.

1 Like

Hello,

Thanks for this report. You are correct. It looks like a change was introduced that assumes payload is an object, although the book uses it as undefined for that example.

I’m going to see if it’s intended that payload cannot be undefined.

Best,
Steve

2 Likes

Hi @kentbull. I submitted a PR to Phoenix that was accepted. This should stop being an issue when the next patch of Phoenix 1.5 is released. When I first checked this bug out, I missed that the documentation still showed channel.push("event") as valid syntax.

1 Like

That’s cool, I’m glad we caught it. Great book by the way, just finished Part 1 and am working on Part 2.

1 Like