Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ability to .catch on CHANNEL::request #4

Closed
iGoodie opened this issue Jan 4, 2025 · 1 comment · Fixed by #6
Closed

Ability to .catch on CHANNEL::request #4

iGoodie opened this issue Jan 4, 2025 · 1 comment · Fixed by #6
Assignees
Labels
enhancement New feature or request

Comments

@iGoodie
Copy link
Member

iGoodie commented Jan 4, 2025

Currently, CHANNEL::request will fail to .catch, if other side errors while handling incoming message.

Make Monorepo-networker support the following scenario:

// ./common/networkSides.ts

export const CLIENT = Networker.createSide("Client-side").listens<{}>();

export const SERVER = Networker.createSide("Server-side").listens<{
  ping(): "pong";
}>();
// ./packages/server/networkChannel.ts

export const SERVER_CHANNEL = SERVER.channelBuilder()
	.receivesFrom(CLIENT, () => { ... })
	.startListening();

SERVER_CHANNEL.registerMessageHandler("ping", () => {
	throw new Error("Wopsie, I failed to pong.")
});
// ./packages/client/main.ts

Networker.initialize(CLIENT, CLIENT_CHANNEL);

CLIENT_CHANNEL.request(SERVER, "ping", [])
	.catch(() => console.log("OH it failed!"));
@iGoodie iGoodie added the enhancement New feature or request label Jan 4, 2025
@iGoodie iGoodie self-assigned this Jan 4, 2025
@iGoodie
Copy link
Member Author

iGoodie commented Jan 8, 2025

Commit 6ac2ca8 resolves this issue

@iGoodie iGoodie linked a pull request Jan 8, 2025 that will close this issue
@iGoodie iGoodie closed this as completed in #6 Jan 8, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant