Skip to content

SockJs included even when excluding web.browser.legacy #12085

@jankapunkt

Description

@jankapunkt

I'm testing some performance things on the client with lighthouse and found that there was still a window.unload listener which is really bad for perf and disabled bf-caching.

I found that SockJS adds this listener: https://github.com/meteor/meteor/blob/devel/packages/socket-stream-client/sockjs-0.3.4.js#L648

However, SockJs should never be loaded to my app, because it's marked as legacy in package.js: https://github.com/meteor/meteor/blob/devel/packages/socket-stream-client/package.js#L18

Repro:

  • create new Meteor Project (my current release is METEOR@2.7.3)
  • run meteor --production --exclude-archs "web.browser.legacy"
  • open source code and search for sockjs you will find it as part of socket-stream-client
  • Meteor.connection._stream.socket gives
{
	  onclose: ()=>{this._lostConnection()}
	  onerror: e=> {}
	  onheartbeat: ()=>{this.lastError=null,this._heartbeat_received()}
	  onmessage: e=> {}
	  onopen: e=>{this.lastError=null,this._connected()}
	  protocol: "websocket"
	  readyState: 1
	  _base_url: "http://localhost:3000/sockjs"
	  _ir: null
	  _options: {devel: false, debug: false, protocols_whitelist: Array(5), info: {}, rtt: 23,}
	  _protocols: ['xhr-polling']
	  _server: "014"
	  _transport: k.websocket {ri: k, url: 'ws://localhost:3000/sockjs/014/decfbp0y/websocket', ws: WebSocket, unload_ref: '0fyje_kk'}
	  _transport_tref: null
}

My assumption is that is line: https://github.com/meteor/meteor/blob/devel/packages/socket-stream-client/browser.js#L11

The import may still cause sockjs to be bundled. If so wouldn't this also mean that all clients forcefully use sockjs, even if they are modern architecure?

Can anyone confirm this issue or give me some insight on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    idleHave'nt a new comment in the last 3 monthsin-discussionWe are still discussing how to solve or implement it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions