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

sockets.forEach is not a function #1782

Comments

@johannesjo
Copy link

Running karma 0.13.16 I encountered the following issue after the last test run successfully:

Missing error handler on `socket`.
TypeError: sockets.forEach is not a function
at disconnectBrowsers (/project-path/node_modules/karma/lib/server.js:314:13)
at [object Object].<anonymous> (/project-path/node_modules/karma/lib/server.js:291:7)
at emitTwo (events.js:92:20)
at [object Object].emit (events.js:172:7)
at emitRunCompleteIfAllBrowsersDone (/project-path/node_modules/karma/lib/server.js:256:12)
at [object Object].<anonymous> (/project-path/node_modules/karma/lib/server.js:278:9)
at emitTwo (events.js:92:20)
at [object Object].emit (events.js:172:7)
at [object Object].onComplete (/project-path/node_modules/karma/lib/browser.js:142:13)
at Socket.<anonymous> (/project-path/node_modules/karma/lib/events.js:13:22)
at emitTwo (events.js:92:20)
at Socket.emit (events.js:172:7)
at Socket.onevent (/project-path/node_modules/socket.io/lib/socket.js:335:8)
at Socket.onpacket (/project-path/node_modules/socket.io/lib/socket.js:295:12)
at Client.ondecoded (/project-path/node_modules/socket.io/lib/client.js:193:14)
at Decoder.Emitter.emit (/project-path/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/project-path/node_modules/socket.io-parser/index.js:247:12)
at Client.ondata (/project-path/node_modules/socket.io/lib/client.js:175:18)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Socket.onPacket (/project-path/node_modules/engine.io/lib/socket.js:101:14)
at emitOne (events.js:77:13)
at WebSocket.emit (events.js:169:7)
at WebSocket.Transport.onPacket (/project-path/node_modules/engine.io/lib/transport.js:93:8)
at WebSocket.Transport.onData (/project-path/node_modules/engine.io/lib/transport.js:104:8)
at WebSocket.onData (/project-path/node_modules/engine.io/lib/transports/websocket.js:76:30)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.ontext (/project-path/node_modules/ws/lib/WebSocket.js:816:10)
at Receiver.parse (/project-path/node_modules/ws/lib/Receiver.hixie.js:145:8)
at doAdd (/project-path/node_modules/ws/lib/Receiver.hixie.js:104:19)
at Receiver.add (/project-path/node_modules/ws/lib/Receiver.hixie.js:108:22)
at Socket.realHandler (/project-path/node_modules/ws/lib/WebSocket.js:800:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)

05 01 2016 23:59:46.725:WARN [PhantomJS 1.9.8 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
JS 1.9.8 (Linux 0.0.0): Executed 42 of 42 DISCONNECTED (10.248 secs / 0.329 secs)
05 01 2016 23:59:46.726:ERROR [karma]: [TypeError: sockets.forEach is not a function]
TypeError: sockets.forEach is not a function
at disconnectBrowsers (/project-path/node_modules/karma/lib/server.js:314:13)
at [object Object].<anonymous> (/project-path/node_modules/karma/lib/server.js:291:7)
at emitTwo (events.js:92:20)
at [object Object].emit (events.js:172:7)
at emitRunCompleteIfAllBrowsersDone (/project-path/node_modules/karma/lib/server.js:256:12)
at [object Object].<anonymous> (/project-path/node_modules/karma/lib/server.js:278:9)
at emitOne (events.js:82:20)
at [object Object].emit (events.js:169:7)
at [object Object]._onTimeout (/project-path/node_modules/karma/lib/browser.js:50:15)
at Timer.listOnTimeout (timers.js:92:15)

/project-path/node_modules/karma/lib/server.js:314
sockets.forEach(function (socket) {
^

TypeError: sockets.forEach is not a function
at disconnectBrowsers (/project-path/node_modules/karma/lib/server.js:314:13)
at process.<anonymous> (/project-path/node_modules/karma/lib/server.js:355:5)
at emitOne (events.js:77:13)
at process.emit (events.js:169:7)
at process._fatalException (node.js:234:26)

I didn't make any changes to the code or to the test itself but reinstalled the node_modules.

@toxicFork
Copy link

Same here, even my previous passing tests are all failing because of this after a node modules reinstall.

@dignifiedquire
Copy link
Member

Thanks for the report, can you please check on the latest version and create a small repo that reproducea this error or point me to your project if it's open source?

@ghost
Copy link

ghost commented Jan 6, 2016

@dignifiedquire We got the same issue in our project. Just take a look at Travis in the bottom:
https://travis-ci.org/trueadm/inferno

Seems to run into a infinity loop just now.

Going to downgrade for now until this is sorted out.

Code that fails is this:

    sockets.forEach(function (socket) {
      socket.removeAllListeners('disconnect')
      if (!socket.disconnected) {
        // Disconnect asynchronously. Socket.io mutates the `sockets.sockets` array
        // underneath us so this would skip every other browser/socket.
        process.nextTick(socket.disconnect.bind(socket))
      }
    })

@toxicFork
Copy link

I tried downgrading and even then I have the same error, was using chrome launcher with karma-mocha if it helps..

msecret pushed a commit to msecret/cf-deck that referenced this issue Jan 6, 2016
Newer versions of karma have an unfixed bug:
karma-runner/karma#1782

Should set to upgrade patch versions automatically after its fixed.
@elicwhite
Copy link

This is due to socket.io bumping to 1.4.0. 1.3.7 worked just fine. We are having this problem too and it is causing our CI to fail.

@toxicFork
Copy link

Does 0.13.15 work?

@dignifiedquire
Copy link
Member

All newer 0.13 releases seem to be broken, as there seems to be some breaking change in socket.io@1.4.0

@toxicFork
Copy link

The issues is in package.json for karma: "socket.io": "^1.3.7", and 1.4.0 matches this (at least http://jubianchi.github.io/semver-check/ says so...)

@dignifiedquire
Copy link
Member

Yes, but breaking backwards compatible changes should only be happening in major bumps, not minor version increases. So the semver range specified is fine in that regard.

@pushups
Copy link

pushups commented Jan 6, 2016

Is this the problem?
socketio/socket.io@b73d9be

@dignifiedquire
Copy link
Member

@pushups probably

@paladox
Copy link

paladox commented Jan 6, 2016

As a workaround try setting this
"socket.io": "1.3.7"

in your package.json.

Meaning not in karmas package.json in your own which is the one requiring karma.

@toxicFork
Copy link

0.13.9 should have socket.io dependency:
"socket.io": "~1.3.5", which doesn't match 1.4.0 in semver, Trying karma@0.13.9 now.

@snowbillr
Copy link

Just tried karma@0.13.9 and it worked.

@toxicFork
Copy link

Confirming karma@0.13.9 works! Anything above it will match socket.io 1.4.0.

@dignifiedquire
Copy link
Member

Patch incoming

@dignifiedquire
Copy link
Member

Just published 0.13.19 which fixes this.

@toxicFork
Copy link

Do you mean 19?

@dignifiedquire
Copy link
Member

Do you mean 19?

yes

@toxicFork
Copy link

OK :D thanks for the fast work! 👏

@ryanmurakami
Copy link

Yes! Thanks for the quick turn around!

@mmahalwy
Copy link

mmahalwy commented Jan 6, 2016

+1 thanks alot!

edmorley pushed a commit to mozilla/treeherder that referenced this issue Jan 6, 2016
socket.io released backwards incompatible API changes in a minor version
update, causing failures during our ui-tests travis run. See:
socketio/socket.io#2368

However the latest version of Karma has added support for it:
karma-runner/karma#1782
@aviman1109
Copy link

I change the version directly on package.json is that right??
Or should I input any thing in terminal??

@aviman1109
Copy link

I succeed!!!!
I input 'npm install socket.io@1.3.5 --save' in command
and it is work~

DavidSouther added a commit to DavidSouther/Montana-News-Archive that referenced this issue Jan 21, 2016
latec added a commit to CSCfi/arvo that referenced this issue Jan 27, 2016
…arma#1782

Päivitetty karma versioon 0.13.19 vinkkien perusteella.
anthonyhastings added a commit to rehabstudio/fe-skeleton-testsuite that referenced this issue Jan 28, 2016
joeyparrish pushed a commit to shaka-project/shaka-player that referenced this issue Jan 28, 2016
socket.io made recent breaking changes to their internals that
older versions of karma uses (See karma-runner/karma#1782).

The old bug with newer karma versions has disappeared and is
assumed fixed (See 817ea3d).

Change-Id: Id1efa635de34f3d864c51c784b2343b8c9d9adee
tfoxy added a commit to tfoxy/js-data that referenced this issue Feb 8, 2016
Fixes error with socket.io mentioned in issue karma-runner/karma#1782
tfoxy added a commit to tfoxy/js-data-http that referenced this issue Feb 8, 2016
Fixes error with socket.io mentioned in issue karma-runner/karma#1782
TJaakkola pushed a commit to CSCfi/arvo that referenced this issue Feb 26, 2016
…arma#1782

Päivitetty karma versioon 0.13.19 vinkkien perusteella.
Romakita added a commit to Romakita/angular-typescript that referenced this issue Mar 7, 2016
@fwielstra
Copy link

I seem to still have this problem with the latest version of Karma:

10 03 2016 17:07:39.954:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
10 03 2016 17:07:39.959:INFO [launcher]: Starting browser PhantomJS
10 03 2016 17:07:40.751:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket /#whtCZIqgWvlZk5nVAAAA with id 56004832
[snip]
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 61 of 862 (4 FAILED) ERROR (0.458 secs / 0.519 secs)
Missing error handler on `socket`.
TypeError: Cannot read property 'charAt' of undefined
    at posix (/project/node_modules/karma-junit-reporter/node_modules/path-is-absolute/index.js:4:13)
    at writeXmlForBrowser (/project/node_modules/karma-junit-reporter/index.js:61:9)
    at onBrowserComplete (/project/node_modules/karma-junit-reporter/index.js:126:5)
    at null.<anonymous> (/project/node_modules/karma/lib/events.js:13:22)
    at emitTwo (events.js:92:20)
    at emit (events.js:172:7)
    at onComplete (/project/node_modules/karma/lib/browser.js:142:13)
    at Socket.<anonymous> (/project/node_modules/karma/lib/events.js:13:22)
    at emitTwo (events.js:92:20)
    at Socket.emit (events.js:172:7)
    at Socket.onevent (/project/node_modules/karma/node_modules/socket.io/lib/socket.js:335:8)
    at Socket.onpacket (/project/node_modules/karma/node_modules/socket.io/lib/socket.js:295:12)
    at Client.ondecoded (/project/node_modules/karma/node_modules/socket.io/lib/client.js:193:14)
    at Decoder.Emitter.emit (/project/node_modules/karma/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
    at Decoder.add (/project/node_modules/karma/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
    at Client.ondata (/project/node_modules/karma/node_modules/socket.io/lib/client.js:175:18)
10 03 2016 17:07:41.710:WARN [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Disconnected (1 times)
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 61 of 862 (4 FAILED) DISCONNECTED (10.462 secs / 0.519 secs)
10 03 2016 17:07:51.712:ERROR [karma]: [TypeError: Cannot read property 'charAt' of undefined]
TypeError: Cannot read property 'charAt' of undefined
    at posix (/project/node_modules/karma-junit-reporter/node_modules/path-is-absolute/index.js:4:13)
    at writeXmlForBrowser (/project/node_modules/karma-junit-reporter/index.js:61:9)
    at onBrowserComplete (/project/node_modules/karma-junit-reporter/index.js:126:5)
    at null.<anonymous> (/project/node_modules/karma/lib/events.js:13:22)
    at emitOne (events.js:82:20)
    at emit (events.js:169:7)
    at null._onTimeout (/project/node_modules/karma/lib/browser.js:50:15)
    at Timer.listOnTimeout (timers.js:92:15)

Any idea what it could be? Tried downgrading to .19, but I had the same problem.

@adam-beck
Copy link

Yep I'm seeing it once again too.

@oliverspryn
Copy link

Yeah, I'm seeing a very similar issue to this. Here are the details: http://stackoverflow.com/questions/35952704/karma-move-folder-missing-error-handler-on-socket

@dignifiedquire
Copy link
Member

These are different issue, the error message is just similar. Please file separate issues

benjamin-albert added a commit to benjamin-albert/dillinger that referenced this issue May 6, 2016
This commit also updates karam to 0.13.22 to avoid
karma-runner/karma#1782 (sockets.forEach is not a function)
when running gulp test.
benjamin-albert added a commit to benjamin-albert/dillinger that referenced this issue May 6, 2016
This commit also updates karam to 0.13.22 to avoid
karma-runner/karma#1782 (sockets.forEach is not a function)
when running gulp test.
benjamin-albert added a commit to benjamin-albert/dillinger that referenced this issue May 7, 2016
This commit also updates karam to 0.13.22 to avoid
karma-runner/karma#1782 (sockets.forEach is not a function)
when running gulp test.
joemccann pushed a commit to joemccann/dillinger that referenced this issue May 8, 2016
This commit also updates karam to 0.13.22 to avoid
karma-runner/karma#1782 (sockets.forEach is not a function)
when running gulp test.
koddsson pushed a commit to koddsson/dillinger that referenced this issue May 16, 2016
This commit also updates karam to 0.13.22 to avoid
karma-runner/karma#1782 (sockets.forEach is not a function)
when running gulp test.
JonathanPorta added a commit to JonathanPorta/Montana-News-Archive that referenced this issue Jun 22, 2016
* Do not merge the same story.

* Actually handle replacing, not merging, records.

* Try to replace tapes, when possible.

* Search UI will handle dates for queries.

* Pasing the correct parameters to the service for search.

* Search client service, not exporting unnecessary things.

* Chore: removing extra whitespace.

* Fix database not being read at startup

* Some layout improvements, breaking start and end dates into explicit fields that can be manually set by the user.

* Add some basic logging on error

* Some layout improvements, breaking start and end dates into explicit fields that can be manually set by the user.

* Expand first/last dates.

* Current record will collapse on background click.

* Adding a new record will set it as current for editing.

* Fixing collapse when middle record is selected.

* Add icon indicators on right side.

* Tests for archive.collapse

* Remove extension importing mock logger.

* Gulpfile makes builds *much* faster.

* Gulp for build; run mocha and karma directly.

* Save on close, and show toast when done.

* Made webpack less verbose in it's output, took out webpack stream.

* Updated mocks.

* Add multimedia to detail view layout

- Adds videos, images, and notes to layout.
- Adds videos and images to the data model.

* Don't let stubs span columns

* Fix some nits.

* Add file upload UI and API route

* Reused TabletTop uploader.

* Uploads save in data/ directory, and load in sidebar.

* Updates after call w/ Stan

* Ensure persisted database when no db present.

* Only show image loader with valid label.

* Miscellaneous.

* Cleaned up date entry.

* Reload data when loading records.

* Added missing static mock.

* When renaming a record, move the images as well.

* Sort by label when find()ing all records.

* Test regression and correctly filter duplicate stories.

* Add static Bootstrap, and augment some elements with bootstrap styles.

* Bump karma version, see karma-runner/karma#1782

* Records now grouped by family

* Futzed with styles for archive record list.

* Use same markup in pre and post.

* no-sticky the subheaders.

* Add toggle between view and edit for record top content.

* Responsive record view

* Initial markup for video association.

* This tweaks a bug with firefox's rendering of md-card. Basically, there is a css prop that sets max height to 100%. Firefox interprets this as the height of the visible viewport rather than 'what is needed', or whatever chrome actually is. By setting this value to inherit, the height is automatically inherited. This works in chrome and firefox.

* Added videos api, and /api/videos/incoming route.

* Tweak class implementation.

* Patch the other card.

* worked in video player to responsive design and moved buttons

* put back real video code

* Changes to labels. Dates crunch and family as a super.

* Hey tests actually run now.

* So, apparently <super> isn't a tag. Changed to <sup> and added md-subheader class to family on record view.

* displays error when server not running

* Tigthen list view and fix icons

* Changed icon for notes

* Fix tests that had bad form, and add Associate route for adding vidoes.

* Displaying incoming videos.

* Associate incoming videos.

* When creating a new record, start in edit state.

* Added documentation on how to set up ./incoming

* Do not try to focus a record when it does not have an input.

* Added image delete button.

* Search bar works and even works right!

* Allow force set of a Record id

* Correct test to use ID convention forced in Record

* Set baseId when id is force set; Update test to check for force set id

* Remove tslint option

* Fix a bunch of breaking things.

* Add a form-level action for searching.

* Unify data/ and incoming/

* Update docs.

* Try ARCHIVE_DATA_ROOT first for image paths.

* And do the same for the list of incoming vidoes.

* finish refactoring basePath and dataPath.

* Moving in a hurry...

* Added debugging for video display.

* Use more correct images url for video.

* Remove console.log

* Changes to adding video

* Don't attempt to save when a current request is in flight.

* Make Notes part of the Editable toggle.

* Add videos safely, and show them immediately.

* This makes the style bar look not as totally horendous.

* Create missing record folders when associating videos.

* When users attempt to move a record into an existing label, don't damage data and tell them why it failed.

* Ensure newly added & saved records have correct baseId.

* URL encodes search and selected record.

BIG BUG: Dates are all mucked up.

* Fix date handling.

* Handle all path permutations.

* Records have a more permissive check for when two stories are equivalent.

* Clarified and simplified story adding and editing.

* Save record when finished editing stories.

* Do not dupe when saving renamed stories.

* Only allow single story to be edited at a time.

* Clearing a story's slug will change save to delete.

* Sets focus on slug when editing story.

* Merge with a real record.

* Search within stories.

* Wait for previous record to close before opening new record.

* Delete button on images confirms, then deletes.

* Sort by family, then first: date.

* Punt on performance, and just hide the FAB when a tape is selected.

* Use mdButton for virtual click on Add Image.

* Delete dialog and button.

* Update media links when renaming records.

* Always anchorscroll when selecting records.

* Apparently we were not merging dates, because we thought they should be computed at one point.

* Consistently enters edit mode when creating a new record.

* Assume that returned media data is canonical.

* Update location when saving and when collapsing.

* Return record data after renaming files, and update in memory record.

* Turns out, failing to remove an image you want removed is not an exceptional case.

* Delete records, as per discussion.

* Actually remove the tape after deleting it.

* Remove the empty directory on delete.

* Make viewing state for notes

* add padding to video player

* put record medium selector in line

* Disable [Delete] when the form is not pristine.

* Do not fail save when data/id dir is not present.

* addressed Davids notes

* a space

* another space
@abbasmoosavi
Copy link

I input 'npm install socket.io@1.3.5 --save' in command
it worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment