language-tools: đ BUG: Astro VSCode extension crashing Typescript language server
Describe the Bug
Unable to work with any TS project because VSCode TS server keeps crashing with the following message.
The JS/TS language service crashed 5 times in the last 5 Minutes. This may be caused by a plugin contributed by one of these extensions: astro-build.astro-vscode, nrwl.angular-console, styled-components.vscode-styled-components, Vue.volar Please try disabling these extensions before filing an issue against VS Code.
Just as the error stated, I disabled all extensions mentioned and manually enabled each one. Eventually, I discovered disabling only astro extension prevented the crash.
Steps to Reproduce
VSCode Version: 1.87.2 Typescript Version: 5.3.2 Astro VSCode Extension Version: 2.8.5 OS: Ubuntu 22.04.4
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 10
- Comments: 15 (6 by maintainers)
I am having the same problem, and have isolated it down to the Astro extension. I have been able to reproduce the error in a freshly created scaffold, where the only things I have added to the empty astro template is react and tailwind.
Here is the GitHub repository
These are the only steps I have done to create this repository:
I then created a directory
src/components/reactand create a single fileReactComponent.tsx.When I open VSCode I get the error, as well as whenever I restart the JS/TS language server.
The error disappears when I disable the Astro extension.
VSCode version information:
Version: 1.90.1 Commit: 611f9bfce64f25108829dd295f54a6894e87339d Date: 2024-06-11T21:44:54.914Z (4 days ago) Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.1.0
Astro extension information:
Version: v2.10.2
@Princesseuh
Same issue here astro Client Crashing in Neovim and VSCode on two Systems this are the lsp.log i get.
[START][2024-05-28 16:42:17] LSP logging initiated [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ âpanic: " [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ âruntime error: index out of range [0] with length 0\nâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â\nâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ âgoroutine " [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â6 [running]:\nâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ âgithub.com/withastro/compiler/internal/printer.renderTsx(â [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â0x1779950â [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â, 0x159da40)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.go:248 +0x1b6\nâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ âgithub.com/withastro/compiler/internal/printer.renderTsx(0x1779950, 0x1582280)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.goâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â:523 +0x52f\ngithub.com/withastro/compiler/internal/printer.renderTsx(0x1779950, 0x1512a00)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f\ngithub.com/withastro/compiler/internal/printer.renderTsx(0x1779950, " [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â0x1512780)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.go:523 +0x52f\ngithub.com/withastro/compiler/internal/printer.renderTsx(0x1779950, 0x1512280)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.go:147 +0xba\ngithub.com/withastro/compiler/internal/printer.PrintToTSX({0x154e000, 0x3bf9}, 0x1512280, {{0x3c3c4, 0x6}, {0x145c0a0, " [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â0x44}, {0x145c0a0, 0x44}, {0x46f38, âŚ}, âŚ}, âŚ)\n\tgithub.com/withastro/compiler/internal/printer/print-to-tsx.go:30 +â [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â0x12\nmain.main.ConvertToTSX.func3({{}, 0x7ff8000100000015, 0x140c790}, {0x1434000, 0x2, 0x2})\n\t./astro-wasm.go:263 +0xe\nsyscall/js.handleEventâ [ERROR][2024-05-28 16:42:17] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ â()\n\tsyscall/js/func.go:100 +0x23\nâ [WARN][2024-05-28 16:42:18] âŚlsp/handlers.lua:625 âexit code: 2â [ERROR][2024-05-28 16:42:18] âŚlsp/handlers.lua:623 âThere was an error transforming /home/bastian/Development/cars-bytes/src/pages/aussteller/[id].astro to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: TypeError: Cannot read properties of undefined (reading âmapâ).â [ERROR][2024-05-28 16:42:18] âŚ/vim/lsp/rpc.lua:770 ârpcâ â/home/bastian/.local/share/nvim/mason/bin/astro-lsâ âstderrâ '/home/bastian/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@astrojs/compiler/dist/node/sync.cjs:1\n"use strictâ;var P=Object.create;var y=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var O=(i,n)=>{for(var s in n)y(i,s,{get:n[s],enumerable:!0})},T=(i,n,s,r)=>{if(n&&typeof n==âobjectâ||typeof n==âfunctionâ)for(let c of A(n))!C.call(i,c)&&c!==s&&y(i,c,{get:()=>n[c],enumerable:!(r=I(n,c))||r.enumerable});return i};var x=(i,n,s)=>(s=i!=null?P(E(i)):{},T(n||!i||!i.__esModule?y(s,âdefaultâ,{value:i,enumerable:!0})đ,i)),D=i=>T(y({},â__esModuleâ,{value:!0}),i);var M={};O(M,{convertToTSX:()=>W,parse:()=>L,startRunningService:()=>R,transform:()=>N});module.exports=D(M);var k=()=>typeof document>âuâ?new URL(âfile:â+__filename).href:document.currentScript&&document.currentScript.src||new URL(âmain.jsâ,document.baseURI).href,w=k();var S=require(âfsâ),j=require(âurlâ);var v=x(require(âcryptoâ),1),b=x(require(âfsâ),1),_=require(âutilâ);globalThis.fs||Object.defineProperty(globalThis,âfsâ,{value:b.default});globalThis.process||Object.defineProperties(globalThis,âprocessâ,{value:process});globalThis.crypto||Object.defineProperty(globalThis,âcryptoâ,{value:v.default.webcrypto?v.default.webcrypto:{getRandomValues(i){return v.default.randomFillSync(i)}}});globalThis.performance||Object.defineProperty(globalThis,âperformanceâ,{value:{now(){let[i,n]=process.hrtime();return i1e3+n/1e6}}});var U=new _.TextEncoder(âutf-8â),V=new _.TextDecoder(âutf-8â);var d=class{constructor(){this.argv=[âjsâ],this.env={},this.exit=e=>{e!==0&&console.warn(âexit code:â,e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let n=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},s=e=>{let t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o4294967296},r=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let o=this.mem.getUint32(e,!0);return this._values[o]},c=(e,t)=>{if(typeof t==ânumberâ&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let m=0;switch(typeof t){case"objectâ:t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,2146959360|m,!0),this.mem.setUint32(e,a,!0)},l=e=>{let t=s(e+0),o=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},g=e=>{let t=s(e+0),o=s(e+8),a=new Array(o);for(let m=0;m<o;m++)a[m]=r(t+m*8);return a},h=e=>{let t=s(e+0),o=s(e+8);return V.decode(new DataView(this._inst.exports.mem.buffer,t,o))},u=Date.now()-performance.now();this.importObject={gojs:{âruntime.wasmExitâ:e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},âruntime.wasmWriteâ:e=>{e>>>=0;let t=s(e+8),o=s(e+16),a=this.mem.getInt32(e+24,!0);b.default.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,a))},âruntime.resetMemoryDataViewâ:e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},âruntime.nanotime1â:e=>{e>>>=0,n(e+8,(u+performance.now())1e6)},âruntime.walltimeâ:e=>{e>>>=0;let t=new Date().getTime();n(e+8,t/1e3),this.mem.setInt32(e+16,t%1e31e6,!0)},âruntime.scheduleTimeoutEventâ:e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn(âscheduleTimeoutEvent: missed timeout eventâ),this._resume()},s(e+8)+1)),this.mem.setInt32(e+16,t,!0)},âruntime.clearTimeoutEventâ:e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},âruntime.getRandomDataâ:e=>{e>>>=0,globalThis.crypto.getRandomValues(l(e+8))},âsyscall/js.finalizeRefâ:e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]â,this._goRefCounts[t]===0){let o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},âsyscall/js.stringValâ:e=>{e>>>=0,c(e+24,h(e+8))},âsyscall/js.valueGetâ:e=>{e>>>=0;let t=Reflect.get(r(e+8),h(e+16));e=this._inst.exports.getsp()>>>0,c(e+32,t)},âsyscall/js.valueSetâ:e=>{e>>>=0,Reflect.set(r(e+8),h(e+16),r(e+32))},âsyscall/js.valueDeleteâ:e=>{e>>>=0,Reflect.deleteProperty(r(e+8),h(e+16))},âsyscall/js.valueIndexâ:e=>{e>>>=0,c(e+24,Reflect.get(r(e+8),s(e+16)))},âsyscall/js.valueSetIndexâ:e=>{e>>>=0,Reflect.set(r(e+8),s(e+16),r(e+24))},âsyscall/js.valueCallâ:e=>{e>>>=0;try{let t=r(e+8),o=Reflect.get(t,h(e+16)),a=g(e+32),m=Reflect.apply(o,t,a);e=this._inst.exports.getsp()>>>0,c(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+56,t),this.mem.setUint8(e+64,0)}},âsyscall/js.valueInvokeâ:e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},âsyscall/js.valueNewâ:e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},âsyscall/js.valueLengthâ:e=>{e>>>=0,n(e+16,parseInt(r(e+8).length))},âsyscall/js.valuePrepareStringâ:e=>{e>>>=0;let t=U.encode(String(r(e+8)));c(e+16,t),n(e+24,t.length)},âsyscall/js.valueLoadStringâ:e=>{e>>>=0;let t=r(e+8);l(e+16).set(t)},âsyscall/js.valueInstanceOfâ:e=>{e>>>=0,this.mem.setUint8(e+24,r(e+8)instanceof r(e+16)?1:0)},âsyscall/js.copyBytesToGoâ:e=>{e>>>=0;let t=l(e+8),o=r(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},âsyscall/js.copyBytesToJSâ:e=>{e>>>=0;let t=r(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(n){if(!(n instanceof WebAssembly.Instance))throw new Error(âGo.run: WebAssembly.Instance expectedâ);this._inst=n,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,r=u=>{let e=s,t=U.encode(u+â\0â);return new Uint8Array(this.mem.buffer,s,t.length).set(t),s+=t.length,s%8!==0&&(s+=8-s%8),e},c=this.argv.length,l=[];this.argv.forEach(u=>{l.push(r(u))}),l.push(0),Object.keys(this.env).sort().forEach(u=>{l.push(r(
${u}=${this.env[u]}))}),l.push(0);let h=s;l.forEach(u=>{this.mem.setUint32(s,u,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(c,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error(âGo program has already exitedâ);this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(n){let s=this;return function(){let r={id:n,this:this,args:arguments};return s._pendingEvent=r,s._resume(),r.result}}};function p(){return f||(f=R()),f}var f,N=(i,n)=>p().transform(i,n),L=(i,n)=>p().parse(i,n),W=(i,n)=>p().convertToTSX(i,n);function R(){let i=new d,n=F((0,j.fileURLToPath)(new URL(ââŚ/astro.wasmâ,w)),i.importObject);i.run(n);let s=globalThis[â@astrojs/compilerâ];return{transform:(r,c)=>{try{return s.transform(r,c||{})}catch(l){throw f=void 0,l}},parse:(r,c)=>{try{let l=s.parse(r,c||{});return{âŚl,ast:JSON.parse(l.ast)}}catch(l){throw f=void 0,l}},convertToTSX:(r,c)=>{try{let l=s.convertToTSX(r,c||{});return{âŚl,map:JSON.parse(l.map)}}catch(l){throw f=void 0,l}}}}function F(i,n){let s=(0,S.readFileSync)(i);return new WebAssembly.Instance(new WebAssembly.Module(s),n)}0&&(module.exports={convertToTSX,parse,startRunningService,transform});\n \n\nError: Go program has already exited\n at d._resume (/home/bastian/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@astrojs/compiler/dist/node/sync.cjs:1:7231)\n at Timeout._onTimeout (/home/bastian/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@astrojs/compiler/dist/node/sync.cjs:1:3722)\n at listOnTimeout (node:internal/timers:573:17)\n at process.processTimers (node:internal/timers:514:7)\n\nNode.js v21.2.0\nâI still cannot do anything without a reproduction or more detailed logs. Everything seems to work fine for me, even when using Svelte and other extensions.
I had the same problem. Try updating your VS Code to the latest version; this is how I solve this error.