Repository navigation
Closed
Description
Steps To Reproduce
- Install atomic extension
- Press continue on setup
- Error :(
ReferenceError: WebSocket is not defined
wr:index.js:9:45398
---
6: `+I+c.join(`,
7: `+I)+`
8: `+i+"}":"{"+c.join(",")+"}",I=i,o}}Wt.exports=function(t,e,r){var n;if(I="",Ie="",typeof r=="number")for(n=0;n<r;n+=1)Ie+=" ";else typeof r=="string"&&(Ie=r);if(ie=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return $e("",{"":t})}});var Gt=se(rt=>{rt.parse=Ft();rt.stringify=qt()});var Zt=se((Jn,Yt)=>{var Le=typeof JSON!="undefined"?JSON:Gt();Yt.exports=function(t,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var r=e.space||"";typeof r=="number"&&(r=Array(r+1).join(" "));var n=typeof e.cycles=="boolean"?e.cycles:!1,o=e.replacer||function(c,a){return a},s=e.cmp&&function(c){return function(a){return function(l,f){var p={key:l,value:a[l]},m={key:f,value:a[f]};return c(p,m)}}}(e.cmp),i=[];return function c(a,l,f,p){var m=r?`
9: `+new Array(p+1).join(r):"",b=r?": ":":";if(f&&f.toJSON&&typeof f.toJS (VERY LONG)
10:
11: `+r)}i()},[t]),t.error?t.error.message:n}async function Bn(t,e,r){let n=await r.getProperty(t),o=e.toString();switch(n.datatype){case"https://atomicdata.dev/datatypes/atomicURL":o=`[${e}](${e})`;break;case"https://atomicdata.dev/datatypes/resourceArray":o="",X(e).map(s=>{o=o+`[${s}](${s}),`});break;case"https://atomicdata.dev/datatypes/timestamp":o=ut(e).toLocaleString();break}return`
12:
---
At.setWebSocket:index.js:9:48511
At.setServerUrl:index.js:9:48427
At:index.js:9:45790
Object.<anonymous>:index.js:13:628
Module._compile:loader:1101:14
Object.Module._extensions..js:loader:1153:10
Module.load:loader:981:32
Function.Module._load:loader:822:12
Module.require:loader:1005:19
I think I know how to fix it: conditional websocket support in @tomic/lib
Activity
joepio commentedon Jan 4, 2022
It seems to work just fine locally with
yarn dev, didn't see an error.Two possible reasons:
#599 Update @tomic/lib for Atomic (#601)
joepio commentedon Jan 5, 2022
After my PR has been merged, my issue continues to happen. I've waited a couple of hours after the updated version was published, I've uninstalled the extension, but it seems my bug isn't fixed. This could happen because my fix wasn't good, or because I'm somehow still running the older version.
The biggest hurdle for me to fixing this, is that the problem does not happen while running
npm run dev. Could thedevversion / runtime differ significantly? Could it be that some runtime errors are hidden for me during development? Or could it be thatWebSocketsis only available in development?@mathieudutour could you perhaps help me with this?
mathieudutour commentedon Jan 5, 2022
you could try with
npm run buildwhich will build the prod version, but yeahWebSocketisn't a NodeJS global so it's expected that it's not available.Keep in mind that the extensions are running in a NodeJS process and not in a browser
joepio commentedon Jan 5, 2022
@mathieudutour
It makes sense that it's not available, I understand it's running in Node, but it's kind of weird that it doesn't crash in
npm run devmode, right? IsWebSocketavailable indevmode, or is the error somehow handled and hidden? It's not appearing in the logs, or popping up.I ran
npm run build, which succeeded, but I don't know where thebuiltversion is stored (can't find adistor.jsanywhere after runningbuild).mathieudutour commentedon Jan 5, 2022
Ah indeed, I found what's happening.
WebSocketandwindoware indeed available indevmode becausereact-dev-toolsrequires them. I'm going to add a warning whenever those global are accessed so that people will know it'll break in prod.So to fix it, you can do something like this:
and add a dependency on
ws.Also, in order to test with the "prod" environment, you can go to the Raycast preferences > Advanced > Use Node production environment.
Sorry for the confusion
joepio commentedon Jan 5, 2022
Thanks for the help and explanation! Turning on the
Node Production environmentsetting makes the error appear, which helps me fix the issue.mathieudutour commentedon Jan 6, 2022
Let me know when it's ready to go :)
joepio commentedon Jan 6, 2022
It's ready to go @mathieudutour!
Thanks!
#599 Update @tomic/lib to v0.30.9 for Atomic Search (#609)
joepio commentedon Jan 6, 2022
It's working!
Update hule extension
Update Teak: folders, Find Similar, done states and more (#32576)
Add app-icons extension (#33140)
Update qrdx-raycast extension