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

requiring socket.io-client no longer works in 4.3.0 #1508

Closed
barisusakli opened this issue Oct 15, 2021 · 2 comments
Closed

requiring socket.io-client no longer works in 4.3.0 #1508

barisusakli opened this issue Oct 15, 2021 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@barisusakli
Copy link

On socket.io-client 4.2.0. I can require it and connect server side like this

const io = require('socket.io-client');
const socket = io(nconf.get('base_url'), {
	path: `/socket.io`,
	extraHeaders: {
		Origin: nconf.get('url'),
		Cookie: cookie,
	},
});

This stopped working with 4.3.0, with the following error. Uncaught TypeError: io is not a function

I have to modify the code to

const socket = io.io(nconf.get('base_url'), {
	path: `/socket.io`,
	extraHeaders: {
		Origin: nconf.get('url'),
		Cookie: cookie,
	},
});

To make it work, not sure if this is intended or a side effect of the changes in 4.3.0.

@barisusakli barisusakli added the bug Something isn't working label Oct 15, 2021
darrachequesne added a commit that referenced this issue Oct 15, 2021
The default export was accidentally removed in [1].

Note: that being said, users are encouraged to use the named exports,
because the default export has a different meaning for CommonJS and ES
modules users.

```js
// BAD
import io from "socket.io-client";

// GOOD
import { io } from "socket.io-client";
```

Related:

- #1505
- #1507
- #1508

[1]: 16b6569
@darrachequesne
Copy link
Member

This was totally not intended. This should be fixed in version 4.3.1, sorry for this.

@darrachequesne darrachequesne added this to the 4.3.1 milestone Oct 16, 2021
@barisusakli
Copy link
Author

@darrachequesne no worries, thanks for the quick fix

sunrise30 added a commit to sunrise30/socket.io-client that referenced this issue Jan 8, 2022
The default export was accidentally removed in [1].

Note: that being said, users are encouraged to use the named exports,
because the default export has a different meaning for CommonJS and ES
modules users.

```js
// BAD
import io from "socket.io-client";

// GOOD
import { io } from "socket.io-client";
```

Related:

- socketio/socket.io-client#1505
- socketio/socket.io-client#1507
- socketio/socket.io-client#1508

[1]: socketio/socket.io-client@16b6569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants