File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const SockJS = require ( 'sockjs-client/dist/sockjs' ) ;
4
4
5
+ // retries variable must increment after each failed reconnection.
6
+ // reconnect time depends on it
7
+ // See https://github.com/webpack/webpack-dev-server/pull/1617
5
8
let retries = 0 ;
6
9
let sock = null ;
7
10
8
11
const socket = function initSocket ( url , handlers ) {
9
12
sock = new SockJS ( url ) ;
10
13
11
- sock . onopen = function onopen ( ) {
12
- retries = 0 ;
13
- } ;
14
+ sock . onopen = function onopen ( ) { } ;
14
15
15
16
sock . onclose = function onclose ( ) {
16
17
if ( retries === 0 ) {
Original file line number Diff line number Diff line change 3
3
const request = require ( 'supertest' ) ;
4
4
const config = require ( './fixtures/simple-config/webpack.config' ) ;
5
5
const helper = require ( './helper' ) ;
6
+ const socket = require ( '../client-src/default/socket.js' ) ;
6
7
7
8
describe ( 'socket options' , ( ) => {
8
9
let server ;
@@ -28,6 +29,23 @@ describe('socket options', () => {
28
29
} ) ;
29
30
} ) ;
30
31
32
+ describe ( 'failing behaviour' , ( ) => {
33
+ beforeEach ( ( done ) => {
34
+ server = helper . start ( config , { } , done ) ;
35
+ req = request ( 'http://localhost:8080' ) ;
36
+ } ) ;
37
+
38
+ it ( 'should increase reconnect time exponentially' , ( ) => {
39
+ // TODO
40
+ // Try to connect to websocket server, ideally with a different
41
+ // origin so it fails to connect
42
+ socket ( "http://localhost:8080/sockjs-node/123/456/websocket" ) ;
43
+ // Inspect socket (retries or retryInMs) to make sure it waits
44
+ // an exponential amount of time and retries variable increases
45
+ // every time
46
+ } ) ;
47
+ } ) ;
48
+
31
49
describe ( 'socksPath option' , ( ) => {
32
50
const path = '/foo/test/bar' ;
33
51
beforeEach ( ( done ) => {
You can’t perform that action at this time.
0 commit comments