"WebSocket.URL" is deprecated. Use 'WebSocket.url' instead

WebSocket connection to 'ws://localhost:35729/livereload' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED chromereload.js:9 'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead. chromereload.js:12 

I get this error message in my chrome extension, since chrome is being updated to version 38. I'm not quite sure what is happening here, but now opening most things will cause the extension to fail. At first, I used yoman to take my project up and everything works fine. I tried removing sheets from the manifest, but that seems to break everything. Any help would be greatly appreciated.

Here is the code:

 'use strict'; // Reload client for Chrome Apps & Extensions. // The reload client has a compatibility with livereload. // WARNING: only supports reload command. var LIVERELOAD_HOST = 'localhost:'; var LIVERELOAD_PORT = 35729; var connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload'); connection.onerror = function (error) { console.log('reload connection got error' + JSON.stringify(error)); }; connection.onmessage = function (e) { if (e.data) { var data = JSON.parse(e.data); if (data && data.command === 'reload') { chrome.runtime.reload(); } } }; 
+7
javascript google-chrome google-chrome-extension
source share
1 answer

In Chrome, this message is issued when using something like JSON.stringify () or a similar WebSocket object. Such routines will have access to the WebSocket.URL property, which is deprecated and issues this warning. Even if your code does not explicitly call WebSocket.URL. You can remove this property to disable the warning from Chrome.

 var ws = new WebSocket('wss://example.com/'); delete ws.URL; console.log(JSON.stringify(ws)); 
+6
source share

All Articles