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

🐛 BUG: Astro Language Server crashing upon launching Visual Studio Code #698

Closed
dylankuipers opened this issue Nov 15, 2023 · 7 comments · Fixed by #717
Closed

🐛 BUG: Astro Language Server crashing upon launching Visual Studio Code #698

dylankuipers opened this issue Nov 15, 2023 · 7 comments · Fixed by #717
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) ecosystem: compiler Issue is caused by a bug in the Astro compiler

Comments

@dylankuipers
Copy link

Describe the Bug

When opening Visual Studio Code I get multiple errors from the Astro extension. The Astro Language Server crashed 5 times in the last 3 minutes and Astro language server closed. I get multiple, really long error messages. This is the error message of a colleague:

`[Info - 12:35:01] Connection to server got closed. Server will restart.
true
panic: runtime error: index out of range [37] with length 37

goroutine 6 [running]:
github.com/withastro/compiler/internal/sourcemap.(ChunkBuilder).GetLineAndColumnForLocation(0x5a7b98, {0x8d})
github.com/withastro/compiler/internal/sourcemap/sourcemap.go:633 +0x11
github.com/withastro/compiler/internal/printer.locToPoint(0x5a7ad0, {0x8d})
github.com/withastro/compiler/internal/printer/print-to-json.go:123 +0x4
github.com/withastro/compiler/internal/printer.positionAt(0x5a7ad0, 0x5d6f00, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:167 +0xd
github.com/withastro/compiler/internal/printer.renderNode(0x5a7ad0, 0x5a7290, 0x5d6f00, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:209 +0x9
github.com/withastro/compiler/internal/printer.renderNode(0x5a7ad0, 0x5a7648, 0x5d6c80, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:267 +0x4b
github.com/withastro/compiler/internal/printer.renderNode(0x5a7ad0, 0x5a7940, 0x5d68c0, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:267 +0x4b
github.com/withastro/compiler/internal/printer.PrintToJSON({0x502ab0, 0x8c}, 0x5d68c0, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:114 +0xc
main.Parse.func1({{}, 0x7ff800010000000d, 0x513cc0}, {0x42c300, 0x2, 0x2})
./astro-wasm.go:225 +0x2b
syscall/js.handleEvent()
syscall/js/func.go:94 +0x26
exit code: 2
/Users/silveltman/.vscode/extensions/astro-build.astro-vscode-2.5.2-darwin-arm64/node_modules/@astrojs/compiler/dist/node/sync.cjs:1
"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}):s,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 i
1e3+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+m8);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={go:{"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[Error - 12:35:01] Server process exited with code 1.
[Info - 12:35:01] Connection to server got closed. Server will restart.
true
panic: runtime error: index out of range [37] with length 37`


And this is the error that I get:

`[Info - 12:38:47 PM] Connection to server got closed. Server will restart.
true
panic: runtime error: index out of range [37] with length 37

goroutine 6 [running]:
github.com/withastro/compiler/internal/sourcemap.(ChunkBuilder).GetLineAndColumnForLocation(0x5afb98, {0x91})
github.com/withastro/compiler/internal/sourcemap/sourcemap.go:633 +0x11
github.com/withastro/compiler/internal/printer.locToPoint(0x5afad0, {0x91})
github.com/withastro/compiler/internal/printer/print-to-json.go:123 +0x4
github.com/withastro/compiler/internal/printer.positionAt(0x5afad0, 0x63ab40, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:167 +0xd
github.com/withastro/compiler/internal/printer.renderNode(0x5afad0, 0x5af290, 0x63ab40, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:209 +0x9
github.com/withastro/compiler/internal/printer.renderNode(0x5afad0, 0x5af648, 0x63a8c0, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:267 +0x4b
github.com/withastro/compiler/internal/printer.renderNode(0x5afad0, 0x5af940, 0x63a500, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:267 +0x4b
github.com/withastro/compiler/internal/printer.PrintToJSON({0x5030e0, 0x90}, 0x63a500, {{0x39edc, 0x7}, 0x1})
github.com/withastro/compiler/internal/printer/print-to-json.go:114 +0xc
main.Parse.func1({{}, 0x7ff800010000000d, 0x5f6bc0}, {0x42c440, 0x2, 0x2})
./astro-wasm.go:225 +0x2b
syscall/js.handleEvent()
syscall/js/func.go:94 +0x26
exit code: 2
c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\node_modules@astrojs\compiler\dist\node\sync.cjs:1
"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}):s,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 i
1e3+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+m8);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={go:{"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});

TypeError: Cannot read properties of undefined (reading 'ast')
at Object.parse (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\node_modules@astrojs\compiler\dist\node\sync.cjs:1:7893)
at L (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\node_modules@astrojs\compiler\dist\node\sync.cjs:1:7556)
at $8 (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:529:2339)
at Yf.onSnapshotUpdated (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:530:11883)
at new Yf (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:530:11520)
at Object.createVirtualFile (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:530:10512)
at Object.updateSource (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:51:6390)
at o (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:51:8512)
at Object.get (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:51:8282)
at d (c:\Users\dylan.vscode\extensions\astro-build.astro-vscode-2.5.2-win32-x64\dist\node\server.js:80:37620)

Node.js v18.15.0
[Error - 12:38:48 PM] Server process exited with code 1.
[Error - 12:38:48 PM] The Astro Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.`

This causes for errors not to be recognized, imports not autocompleting and more. Is this an issue in the extension or something that we are doing wrong?

Steps to Reproduce

  1. Install the astro languge support plugin
  2. Restart your Visual Studio Code
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 15, 2023
@dylankuipers dylankuipers changed the title 🐛 BUG: 🐛 BUG: Astro Language Server crashing upon launching Visual Studio Code Nov 15, 2023
@dylankuipers
Copy link
Author

^^^

It also gives me this error in the output:

[Error - 12:57:56] Stopping server failed Message: Pending response rejected since connection got disposed Code: -32097 [Error - 12:57:56] Stopping server failed Message: Pending response rejected since connection got disposed Code: -32097

@dylankuipers
Copy link
Author

dylankuipers commented Nov 15, 2023

Update:

In my component with the name "Price.astro" I had this code:

---
const {price, class: className} = Astro.props;
---

<span class="text-hue11" class:list={className}>€{price.toFixed(2)} ex. btw</span>

We realised this was causing the issue of "reading 'ast'" via linter. After removing this component then adding it back and replacing the code with:

---
const {price, class: className} = Astro.props;
---

<span class:list={{className, 'text-hue11'}}>€{price.toFixed(2)} ex. btw</span>

It magically started working again and we are no longer getting the error. My conspiracy is that VS Code and what I was seeing was not correctly synced, so VS Code thought it said: Ast.props instead of Astro.props. Although this would still not explain the lowercase "a" in the error message.

I hope this is of any help and that the issue no longer continues. This could possibly still be an issue with the plugin and/or with VS Code so I will keep the issue up :)

@Princesseuh
Copy link
Member

No, ast here stands for AST, as in https://en.wikipedia.org/wiki/Abstract_syntax_tree.

This is somewhat related to #623

@dylankuipers
Copy link
Author

Oh okay, thank you! So this error won't come back then I assume? And is it being worked on or is this just something to deal with ourselves?

@Princesseuh
Copy link
Member

Definitely something we need to fix on our (Astro) side, it definitely shouldn't be happening to you often!

@dylankuipers
Copy link
Author

Perfect, thanks! Should I (or you) close the issue for duplicate issue that you mentioned?

@Princesseuh
Copy link
Member

I think those issues are related, but I don't think they're necessarily the same, I'll keep both opened for now!

@Princesseuh Princesseuh added - P4: important Violate documented behavior or significantly improves performance (priority) ecosystem: compiler Issue is caused by a bug in the Astro compiler and removed needs triage Issue needs to be triaged labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) ecosystem: compiler Issue is caused by a bug in the Astro compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants