Skip to content

Minor: Event handler of 'offline' event must be added on the initial evaluation of worker script on Service Worker #5125

Closed
@wanfahmi11

Description

@wanfahmi11

Describe the bug
Getting a warning when including socket.io client to service worker:

image

Event handler of 'offline' event must be added on the initial evaluation of worker script on Service Worker

To Reproduce

Socket.IO server version: 4.7.4

Server

import { Server } from "socket.io";

const io = new Server(3000, {});

io.on("connection", (socket) => {
  console.log(`connect ${socket.id}`);

  socket.on("disconnect", () => {
    console.log(`disconnect ${socket.id}`);
  });
});

Socket.IO client version: 4.7.4

Client

import { io } from "socket.io-client";

const socket = io("ws://localhost:3000/", {});

socket.on("connect", () => {
  console.log(`connect ${socket.id}`);
});

socket.on("disconnect", () => {
  console.log("disconnect");
});

Expected behavior
Probably can skip adding "offline" event listener for service worker, since it's already skipped it for offline, I don't see any harm skipping it for service worker.

Platform:

  • Device: [e.g. Samsung S8]
  • OS: [e.g. Android 9.2]

Additional context
I would like to contribute myself but I can't find the exact line to modify. I can find the codes in dist/socket.io.js but I'm not sure if that's the right file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions