Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

docs: fix conjunction with fastify example #5057

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KartikeSingh
Copy link

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

Right now the readme example directly uses app.io in the conjunction with fastify example but io is undefined while the server (app) is not ready

const app = require('fastify')();
app.register(require('fastify-socket.io'));
app.io.on('connection', () => { /* … */ }); // here io is undefined
app.listen(3000);

New behavior

Now app.io is accessed after the server (app) is ready so it is defined

const app = require('fastify')();
app.register(require('fastify-socket.io'));
app.ready().then(() => {
    app.io.on('connection', () => { /* … */ }); // here app.io is defined
});
app.listen(3000);

Other information (e.g. related issues)

I was using it for the first time and got confused if I installed something wrong, then after diving into the detailed docs I understood what I was doing wrong.
Couldn't find this issue on my first few google searches, so fixing the readme should save a lot of trouble for other fastify users

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.

None yet

1 participant