PKU400: Missing Channel Name
Error Message
[PKU400] Channel name is required
What Went Wrong
You're trying to register a channel without providing a name property. Every channel needs a unique name for identification.
How to Fix
Add a name property to your channel registration:
import { addChannel } from '@pikku/core/channel'
import { pikkuFunc } from '#pikku'
const onConnect = pikkuFunc(async () => {
console.log('Client connected')
})
const onMessage = pikkuFunc(async (message: string) => {
return { echo: message }
})
addChannel({
name: 'chat', // ✅ Add this
onConnect,
onMessageWiring: {
message: onMessage,
},
})
Channel Naming Best Practices
- Use lowercase, descriptive names
- Consider using kebab-case for multi-word names (e.g.,
user-notifications) - Keep names simple and memorable
- Avoid special characters except hyphens
Common Channel Patterns
// Real-time chat
addChannel({
name: 'chat',
onConnect: handleConnect,
onMessageWiring: {
sendMessage: handleMessage,
typing: handleTyping,
},
})
// Live notifications
addChannel({
name: 'notifications',
onConnect: subscribeToNotifications,
onMessageWiring: {
subscribe: handleSubscribe,
unsubscribe: handleUnsubscribe,
},
})
// Game state
addChannel({
name: 'game-state',
onConnect: joinGame,
onDisconnect: leaveGame,
onMessageWiring: {
move: handleMove,
action: handleAction,
},
})
Common Mistakes
- Omitting the
nameproperty entirely - Using an empty string
- Using spaces in channel names
- Using uppercase letters (while allowed, lowercase is conventional)