0

Just like in V2 i can easily use socket.io in my background.js

  • let socket = io.connect(url);

  • But now i've to migrate V2 to v3 and I want to use socket but know i'm getting this error "Error handling response: ReferenceError: io is not defined"

  • Is there any way to use socket io in my service worker (background.js)? Thanks

  • Another Question is ---> is socket io versions need to be same on both sides (client and server)?

Ahsan Hafeez
  • 11
  • 1
  • 1
  • 5
  • See [How to import a js file in a Chrome extension service worker?](https://stackoverflow.com/questions/74413670/how-to-import-a-js-file-in-a-chrome-extension-service-worker/74414528#74414528) – Thomas Mueller Nov 18 '22 at 13:40
  • @ThomasMueller i read this answer but the issue is my socket.io version isn't ES Module. Version is (2.2.0). – Ahsan Hafeez Nov 18 '22 at 22:26
  • Sometimes I don't understand obvious things, so please pardon me for asking: Why are you using a socket.io version that's 4 years old? – Thomas Mueller Nov 18 '22 at 22:33
  • @ThomasMueller because it is the requirement of server side, socket.io version is need to be less than 2.2.0. And i can’t make any changes to server side because i have no access to that. – Ahsan Hafeez Nov 19 '22 at 18:14

0 Answers0