Commit Graph

7697 Commits

Author SHA1 Message Date
Damien Arrachequesne
851c1177fc chore(release): 4.0.1
Diff: https://github.com/socketio/engine.io-parser/compare/4.0.0...4.0.1
2020-09-11 00:49:45 +02:00
Damien Arrachequesne
886f9ea7c4 fix: use a terser-compatible representation of the separator
By default, terser (the mangler used by webpack) will replace the '\x1e'
by an unreadable character in the optimized output.

One solution would be to use the 'ascii_only' option:

```
module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          output: {
            ascii_only: true
          }
        }
      })
    ]
  }
};
```

But it would require anyone who tries to bundle the engine.io client to
use this plugin, so we'll rather use String.fromCharCode().

Note: String.fromCharCode(30) === '\u001e' === '\x1e'
2020-09-11 00:24:56 +02:00
Damien Arrachequesne
9df38d57fb docs: update the list of supported engines
As Node.js 8 is now EOL.
2020-09-10 15:52:32 +02:00
Damien Arrachequesne
078527a384 feat: disable perMessageDeflate by default
The WebSocket permessage-deflate extension, while useful is some cases,
adds some extra memory overhead for each WebSocket connection, and
results in huge memory usage in production deployments.

It will now be disabled by default.
2020-09-10 15:46:04 +02:00
Damien Arrachequesne
54c67978d5 docs: update the default value of maxHttpBufferSize
Following 734f9d1268
2020-09-10 15:22:43 +02:00
Damien Arrachequesne
1916d3ae62 test: remove Node.js 8 from the test matrix
Reference: https://github.com/nodejs/Release
2020-09-10 15:20:00 +02:00
Damien Arrachequesne
4683a954d4 chore: provide a development bundle
Two bundles will now be created:

- one for development, with debug and unminified: dist/engine.io.js
- one for production, without debug and minified: dist/engine.io.min.js
2020-09-10 15:17:53 +02:00
Damien Arrachequesne
14ca7a1cfc chore: restore package-lock.json file
The package-lock.json file was removed in the previous commit, in order
to sync the client version when upgrading the parser (and make the
tests pass).
2020-09-09 02:09:44 +02:00
Damien Arrachequesne
f7ba966e53 feat: strip debug from the browser bundle
Striping the debug module (both imports and method calls) helps
reduce the bundle size from 41 to 33 KB.

Note: while removing debug from the source code is not desirable, it
might be interesting to provide the library without debug included, so
that users don't have to use something like webpack-remove-debug when
bundling the library.
2020-09-09 01:53:22 +02:00
Damien Arrachequesne
ab3de6ab53 test: add Node.js 14 in the test matrix
Reference: https://github.com/nodejs/Release
2020-09-09 01:36:13 +02:00
Damien Arrachequesne
8440a57f76 chore: bump engine.io-parser version
See also: https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4

Release: https://github.com/socketio/engine.io-parser/releases/tag/4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.2.0...4.0.0
2020-09-09 00:02:24 +02:00
Damien Arrachequesne
ed29e5955d chore: bump engine.io-parser version
See also: https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4

Release: https://github.com/socketio/engine.io-parser/releases/tag/4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.2.0...4.0.0
2020-09-09 00:00:25 +02:00
Damien Arrachequesne
01df755d4b docs: update README 2020-09-08 23:30:51 +02:00
Damien Arrachequesne
ebf6e8cd49 chore(release): 4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.1...v4.0.0
2020-09-08 23:15:39 +02:00
Damien Arrachequesne
03b49674e6 chore: bump cookie version
Release: https://github.com/jshttp/cookie/releases/tag/v0.4.0
Diff: https://github.com/jshttp/cookie/compare/v0.3.1...v0.4.1
2020-09-08 02:47:18 +02:00
Gal Koren
cabb78d666 chore: bump parseqs version (#639)
Release notes: https://github.com/galkn/querystring/releases/tag/v0.0.6
2020-09-08 01:54:50 +02:00
Damien Arrachequesne
eb2d8cc4c6 test: add Node.js 14 in the test matrix
Ref: https://github.com/nodejs/Release
2020-09-08 01:31:17 +02:00
Damien Arrachequesne
8edf2d1478 fix: keep track of the buffer initial length
The write buffer is mutable, so its initial length must be saved when
encoding the payload.
2020-09-08 01:30:32 +02:00
Damien Arrachequesne
6efedfa0f3 feat: restore the upgrade mechanism
See 660263fae2
2020-09-08 01:30:32 +02:00
Damien Arrachequesne
66287d919f test: pin the Node.js version for the browser tests
The build fails with Node.js 12. Let's pin the version for now, we'll
investigate later.
2020-09-08 01:30:21 +02:00
dependabot[bot]
373886f195 chore: bump elliptic from 6.5.2 to 6.5.3 (#115)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-07 13:23:44 +02:00
Damien Arrachequesne
660263fae2 docs: restore the upgrade mechanism in v4
After re-reading the goals of Engine.IO [1], it seems the upgrade
mechanism is better for the user experience, so we'll keep that way.

[1] https://github.com/socketio/engine.io#goals
2020-09-07 13:18:54 +02:00
Damien Arrachequesne
e0b35d054f docs: points towards the website
The website is now much more stable, so there's no need to keep two
copies of the same content (which must be manually kept in sync).
2020-09-01 09:37:29 +02:00
Damien Arrachequesne
a66f083d3e docs(examples): add create-react-app example
Related: https://github.com/socketio/socket.io-client/issues/1330
2020-07-09 11:32:48 +02:00
Damien Arrachequesne
f5a8f52f19 docs(examples/react-native): update video 2020-06-05 21:36:15 +02:00
Damien Arrachequesne
7a219f9459 docs(examples/react-native): add example with React Native
Includes e5bc1063cc
2020-06-05 08:57:04 +02:00
Damien Arrachequesne
5d16319692 docs(examples/webpack-build-server): update engine.io version
In order to include [0], which fixes the following error:

ERROR in ./node_modules/engine.io/lib/server.js
Module not found: Error: Can't resolve 'uws' in '/media/damien/git/other-bets/socket.io-parent/socket.io/examples/webpack-build-server/node_modules/engine.io/lib'
 @ ./node_modules/engine.io/lib/server.js 107:27-41
 @ ./node_modules/engine.io/lib/engine.io.js
 @ ./node_modules/socket.io/lib/index.js
 @ ./lib/index.js

[0] 85e544afd9
2020-06-04 16:36:19 +02:00
Damien Arrachequesne
09708eb307 docs(changelog): include changelog for release 3.4.2
Merged from the 3.4.x branch.
2020-06-04 16:23:05 +02:00
Damien Arrachequesne
82cdca23ba fix: remove implicit require of uws
So that bundlers like webpack do not try to include it in the build.

As a side-effect, any implementation which matches the API of the ws
module can now be used.

Before that change, you had to explicitly exclude uws:

```
// webpack.config.js
module.exports = {
  // ...
  externals: {
     uws: 'uws'
  }
};
```

Related: https://github.com/socketio/engine.io/issues/575
2020-06-04 14:24:42 +02:00
Damien Arrachequesne
a5e76bc011 docs: add example with extraHeaders in the browser 2020-06-04 10:20:42 +02:00
Damien Arrachequesne
dac76f249b docs: use ES6 syntax for the code examples 2020-06-04 10:09:22 +02:00
Damien Arrachequesne
d5d81a7c75 chore: bump component-emitter dependency
Subscribing/unsubscribing for a lot of different event types could lead
to a memory leak.

See aa2e57acc7

Diff: https://github.com/component/emitter/compare/1.2.1...1.3.0
2020-06-04 08:12:10 +02:00
Damien Arrachequesne
f3a48329e7 test: restore tests on all browsers
iphone / ipad / edge were excluded in [1], though there is no clear
explanation.

[1] 28765c5430
2020-06-04 07:43:47 +02:00
Damien Arrachequesne
2f5c948abe fix(react-native): restrict the list of options for the WebSocket object
Only 'headers' and 'localAddress' options are supported by the
WebSocket implementation in React Native.

The following message was printed to the console:

> Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?

Reference: https://reactnative.dev/docs/network.html#websocket-support
2020-05-25 07:34:17 +02:00
Damien Arrachequesne
8f90ba9c67 docs(examples): add example with passport authentication 2020-05-22 08:36:43 +02:00
Damien Arrachequesne
3dd2a0ea41 chore(release): 4.0.0-alpha.1
Diff: https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.0...v4.0.0-alpha.1
2020-05-19 15:15:20 +02:00
Damien Arrachequesne
cab7db0404 feat: implement the version 4 of the protocol
See https://github.com/socketio/engine.io-protocol for the list of
changes.

Note: The 'base64-arraybuffer' dependency must now be explicitly
included by the client (not needed by the server).
2020-05-19 15:07:53 +02:00
Damien Arrachequesne
cf3a759b89 docs: fix typo 2020-05-19 14:36:20 +02:00
Damien Arrachequesne
9806892ea5 docs: describe revision 4 of the protocol
This version is still subject to change, feedback is welcome!

The rationale behind the changes are listed in the relevant section.
2020-05-19 14:18:02 +02:00
Damien Arrachequesne
1aec01ab18 docs: add table of contents 2020-05-19 12:50:11 +02:00
Damien Arrachequesne
c725310be0 docs: add reference to version 2 2020-05-19 12:41:39 +02:00
Damien Arrachequesne
725d551b75 docs: add some additional examples for the protocol v3 2020-05-19 12:12:25 +02:00
Damien Arrachequesne
a8130ce3a9 chore: release 3.4.1
Diff: https://github.com/socketio/socket.io-parser/compare/3.4.0...3.4.1
2020-05-13 07:59:21 +02:00
bcaller
dcb942d24d fix: prevent DoS (OOM) via massive packets (#95)
When maxHttpBufferSize is large (1e8 bytes), a payload of length 100MB
can be sent like so:

99999991:422222222222222222222222222222222222222222222...

This massive packet can cause OOM via building up many many
`ConsOneByteString` objects due to concatenation:
99999989 `ConsOneByteString`s and then converting the massive integer to
a `Number`.

The performance can be improved to avoid this by using `substring`
rather than building the string via concatenation.

Below I tried one payload of length 7e7 as the 1e8 payload took so
long to process that it timed out before running out of memory.

```
==== JS stack trace =========================================

    0: ExitFrame [pc: 0x13c5b79]
Security context: 0x152fe7b808d1 <JSObject>
    1: decodeString [0x2dd385fb5d1] [/node_modules/socket.io-parser/index.js:~276] [pc=0xf59746881be](this=0x175d34c42b69 <JSGlobal Object>,0x14eccff10fe1 <Very long string[69999990]>)
    2: add [0x31fc2693da29] [/node_modules/socket.io-parser/index.js:242] [bytecode=0xa7ed6554889 offset=11](this=0x0a2881be5069 <Decoder map = 0x3ceaa8bf48c9>,0x14eccff10fe1 <Very...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa09830 node::Abort() [node]
 2: 0xa09c55 node::OnFatalError(char const*, char const*) [node]
 3: 0xb7d71e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb7da99 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd2a1f5  [node]
 6: 0xd2a886 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xd37105 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xd37fb5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xd3965f v8::internal::Heap::HandleGCRequest() [node]
10: 0xce8395 v8::internal::StackGuard::HandleInterrupts() [node]
11: 0x1042cb6 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x13c5b79  [node]
```
2020-05-13 07:37:32 +02:00
Damien Arrachequesne
a5d04354e6 test: transpile to es5 with babelify 2020-05-13 07:23:37 +02:00
Damien Arrachequesne
86d4e8d4da docs(changelog): include changelog for release 3.4.1
Merged from the 3.4.x branch.
2020-04-17 15:08:17 +02:00
Damien Arrachequesne
94623c8f8b docs(changelog): include changelog for release 3.4.1
Merged from the 3.4.x branch.
2020-04-17 14:57:35 +02:00
Damien Arrachequesne
2a1aa1c59c docs(examples): bump dependencies
In order to include https://github.com/socketio/engine.io/releases/tag/3.4.1
2020-04-17 14:37:31 +02:00
Damien Arrachequesne
17747e4d69 docs(chat-example): bump dependencies
In order to include https://github.com/socketio/engine.io/releases/tag/3.4.1
2020-04-17 11:21:10 +02:00
Damien Arrachequesne
3f3a6f9914 fix: use globalThis polyfill instead of self/global (#634)
In order to fix the "self is not defined" issues in Android 8 and React
Native.

Fixes https://github.com/socketio/engine.io-client/issues/611, https://github.com/socketio/engine.io-client/issues/626
Closes https://github.com/socketio/engine.io-client/pull/627
2020-04-16 16:08:37 +02:00