Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Are there any plans to implement prepared writes?

Open
#546 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
go

Research direction

Start by reviewing the library's existing websocket.Conn write API and the proposed PrepareMessage and WritePrepared entry points, then compare the cited gorilla/websocket and lxzan/gws behavior. Establish the API, compression interactions, and message lifecycle before implementation; done means an agreed design that supports reuse for identical broadcasts.

Written by the indexing model from the issue text.

Description

I'm currently working on a websocket-based broadcasting server and would be more then happy to use this great library, but there is no prepared writes functionality, like in some other websocket libraries (e.g. gorilla/websocket and lxzan/gws). This would help a lot to optimize the broadcasting of identical messages. Are there any plans to implement this feature in some way (or accept PRs that implements it)?

I'm not sure how the API should look like, but it would be cool to have something similar.

var connections []*websocket.Conn

// Create prepared message without frames generation.
pm := websocket.PrepareMessage(websocket.MessageText, []byte("hello"))
defer pm.Close()

for _, c := range connections {
    // Lazily initialize frame buffer for "pm" and reuse it for other connections.
    // For each set of compression settings (mode and threshold), there will be separate pre-initialized frame
    // buffers, so if some connections don't have compression enabled and some do have, then two types of
    // frame buffers will be initialized for each of them.
	if err := c.WritePrepared(ctx, pm); err != nil {
		log.Printf("failed to write prepared message: %v\n", err)
	}
}
Dominant language
Go
Stars
5.5k
Forks
377
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/websocket

All issues in coder/websocket

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.