rescript-lang / rescript-lang/rescript-vscode
rescriptls quit with exit code 1 and signal 0
Nobody has claimed this yet.
- Dominant language
- ReScript
- Stars
- 354
- Forks
- 63
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 1
Description
I can't get rescript-language-server working in my NeoVim w/
return {
{ "rescript-lang/vim-rescript", ft = "rescript" },
{
"neovim/nvim-lspconfig",
opts = {
servers = {
rescriptls = {
mason = false,
},
},
},
},
}
where I manually installed rescript-language-server 1.62.0 on my Nix-managed NeoVim.
Here is a log:
Log
[ERROR][2025-07-03 23:53:46] ...p/_transport.lua:36"rpc" "rescript-language-server" "stderr" "/nix/store/smsf3d20n08h6h03b8hix19i6273nc14-rescript-language-server-1.62.0/lib/node_modules/@rescript/language-server/out/cli.js:42\n${h}
);let v={type:yh.MessageType.Warning,message:[Incremental typechecking] Something might have gone wrong with incremental type checking. Check out the error log and report this issue please.};n({jsonrpc:Z,method:\"window/showMessage\",params:v})}catch(j){console.error(j)}let M={jsonrpc:Z,method:\"textDocument/publishDiagnostics\",params:{uri:(0,Ac.pathToFileURL)(t.file.sourceFilePath),diagnostics:N}};n(M)}r?.()});t.killCompilationListeners.push(()=>{a.kill(\"SIGKILL\")})}catch(a){console.error(a)}}function Dh(t,e,n,r){ht()&&console.log(\"Updated: \"+t),Yv(t,e,n,r)}function Ph(t){ht()&&console.log(\"Closed: \"+t);let e=jn.get(t);e!=null&&(wh(t,e.project.rootPath),jn.delete(t),Nc.delete(e.file.originalTypeFileLocation),bh.unwatch([e.file.originalTypeFileLocation]))}function Eh(t){let e=jn.get(t);return e!=null?e.codeActions:null}var Lc={},Oc=null,jc=!1,Hc=0,Ic=!1,Zr=new Map,Ah={},ne=t=>{},qh=t=>le.extensionConfiguration.binaryPath==null?_n(t,pe.join(Zn,Jn)):so(le.extensionConfiguration.binaryPath,Jn),Zv=new ti.RequestType(\"textDocument/createInterface\"),ew=new ti.RequestType(\"textDocument/openCompiled\"),tw=t=>{let e=null;return Ve.forEach((n,r)=>{e==null&&n.filesDiagnostics[t]!=null&&(e=n.filesDiagnostics[t].slice())}),e??[]},nw=()=>{Ve.forEach((t,e)=>{let{filesWithDiagnostics:n}=t,r=pe.join(e,Ji),i=$e.default.readFileSync(r,{encoding:\"utf-8\"}),{done:o,result:s,codeActions:a,linesWithParseErrors:u}=ao(i);if(u.length>0){let p={type:B.MessageType.Warning,message:There are more compiler warning/errors that we could not parse. You can help us fix this by opening an issue on the repository, pasting the contents of the file lib/bs/.compiler.log.};ne({jsonrpc:Z,method:\"window/showMessage\",params:p})}t.filesDiagnostics=s,Ah=a,Object.keys(s).forEach(p=>{let h={uri:p,diagnostics:s[p]};ne({jsonrpc:Z,method:\"textDocument/publishDiagnostics\",params:h}),n.add(p)}),o&&n.forEach(p=>{s[p]==null&&(ne({jsonrpc:Z,method:\"textDocument/publishDiagnostics\",params:{uri:p,diagnostics:[]}}),n.delete(p))})})},rw=t=>{let e=Ve.get(t);e!=null&&(e.filesWithDiagnostics.forEach(n=>{ne({jsonrpc:Z,method:\"textDocument/publishDiagnostics\",params:{uri:n,diagnostics:[]}})}),Ve.delete(t),le.extensionConfiguration.incrementalTypechecking?.enable&&Fc(t))},iw=()=>{ne({jsonrpc:Z,method:\"rescript/compilationFinished\"})},ar=!1,Nh=t=>{try{ar&&console.log(\"syncing project config cache for \"+t),Vt(t,[\"cache-project\",t]),ar&&console.log(\"OK - synced project config cache for \"+t)}catch(e){ar&&console.error(e)}},ow=t=>{try{ar&&console.log(\"deleting project config cache for \"+t),Vt(t,[\"cache-delete\",t]),ar&&console.log(\"OK - deleted project config cache for \"+t)}catch(e){ar&&console.error(e)}},ei=xh.watch([],{awaitWriteFinish:{stabilityThreshold:1}}).on(\"all\",(t,e)=>{if(e.includes(\"build.ninja\")){if(le.extensionConfiguration.cache?.projectConfig?.enable===!0){let n=wt(e);n!=null&&Nh(n)}}else try{nw(),iw(),le.extensionConfiguration.inlayHints?.enable===!0&&Fh(),le.extensionConfiguration.codeLens===!0&&Oh()}catch{console.log(\"Error while sending updated diagnostics\")}}),sw=()=>{ei.close()},aw=(t,e)=>{let n=(0,Se.fileURLToPath)(t);Zr.set(n,e);let r=wt(n);if(r!=null){let i=Ve.get(r);if(i==null){le.extensionConfiguration.incrementalTypechecking?.enable&&vh(r);let a=Wr(r);i={openFiles:new Set,filesWithDiagnostics:new Set,filesDiagnostics:{},namespaceName:a.kind===\"success\"?a.result:null,rescriptVersion:Na(r),bsbWatcherByEditor:null,bscBinaryLocation:pd(r),editorAnalysisLocation:md(r),hasPromptedToStartBuild:/(\\/|\\\\)node_modules(\\/|\\\\)/.test(r)?\"never\":!1},Ve.set(r,i),ei.add(pe.join(r,Ji)),le.extensionConfiguration.cache?.projectConfig?.enable===!0&&(ei.add(pe.join(r,Ir)),Nh(r))}Ve.get(r).openFiles.add(n);let s=pe.join(r,Ul);if(i.hasPromptedToStartBuild===!1&&le.extensionConfiguration.askToStartBuild===!0&&!$e.default.existsSync(s))if(qh(r)!=null){let a={title:Ta,projectRootPath:r},u={type:B.MessageType.Info,message:\"Start a build for this project to get the freshest data?\",actions:[a]},p={jsonrpc:Z,id:Hc++,method:\"window/showMessageRequest\",params:u};ne(p),i.hasPromptedToStartBuild=!0}else{let a={jsonrpc:Z,method:\"window/showMessage\",params:{type:B.MessageType.Error,message:le.extensionConfiguration.binaryPath==null?Can't find ReScript binary in ${pe.join(r,Zn)} or parent directories. Did you install it? It's required to use "rescript" > 9.1:Can't find ReScript binary in the directory ${le.extensionConfiguration.binaryPath}}};ne(a)}}},cw=t=>{let e=(0,Se.fileURLToPath)(t);le.extensionConfiguration.incrementalTypechecking?.enable&&Ph(e),Zr.delete(e);let n=wt(e);if(n!=null){let r=Ve.get(n);r!=null&&(r.openFiles.delete(e),r.openFiles.size===0&&(ei.unwatch(pe.join(n,Ji)),ei.unwatch(pe.join(n,Ir)),ow(n),rw(n),r.bsbWatcherByEditor!==null&&(r.bsbWatcherByEditor.kill(),r.bsbWatcherByEditor=null)))}},uw=(t,e)=>{let n=(0,Se.fileURLToPath)(t);(0,Mc.assert)(Zr.has(n)),Zr.set(n,e),le.extensionConfiguration.incrementalTypechecking?.enable&&Dh(n,e,ne,()=>{le.extensionConfiguration.codeLens&&Oh(),le.extensionConfiguration.inlayHints&&Fh()})},Ln=t=>{let e=(0,Se.fileURLToPath)(t),n=Zr.get(e);return(0,Mc.assert)(n!=null),n};function Ao(t=!1){if(t){let e=new xo.StreamMessageWriter(In.default.stdout),n=new xo.StreamMessageReader(In.default.stdin);ne=r=>e.write(r),n.listen(kh)}else ne=e=>In.default.send(e),In.default.on(\"message\",kh)}function lw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Ln(e.textDocument.uri),i=on();$e.default.writeFileSync(i,r,{encoding:\"utf-8\"});let o=Ct(n,[\"hover\",n,e.position.line,e.position.character,i,!!Lc.supportsMarkdownLinks],t);return $e.default.unlink(i,()=>null),o}function dw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri);return Ct(n,[\"inlayHint\",n,e.range.start.line,e.range.end.line,le.extensionConfiguration.inlayHints?.maxLength],t)}function Fh(){let t={jsonrpc:Z,method:B.InlayHintRefreshRequest.method,id:Hc++};ne(t)}function fw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri);return Ct(n,[\"codeLens\",n],t)}function Oh(){let t={jsonrpc:Z,method:B.CodeLensRefreshRequest.method,id:Hc++};ne(t)}function hw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Ln(e.textDocument.uri),i=on();$e.default.writeFileSync(i,r,{encoding:\"utf-8\"});let o=Ct(n,[\"signatureHelp\",n,e.position.line,e.position.character,i,le.extensionConfiguration.signatureHelp?.forConstructorPayloads?\"true\":\"false\"],t);return $e.default.unlink(i,()=>null),o}function pw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri);return Ct(n,[\"definition\",n,e.position.line,e.position.character],t)}function mw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri);return Ct(n,[\"typeDefinition\",n,e.position.line,e.position.character],t)}function gw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Fa(n,e.position);return{jsonrpc:Z,id:t.id,result:r}}function yw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Fa(n,e.position),i=null;return r!==null&&r.forEach(o=>{if(pe.normalize((0,Se.fileURLToPath)(o.uri))===pe.normalize((0,Se.fileURLToPath)(e.textDocument.uri))){let{start:s,end:a}=o.range,u=e.position;s.character<=u.character&&s.line<=u.line&&a.character>=u.character&&a.line>=u.line&&(i=o.range)}}),{jsonrpc:Z,id:t.id,result:i}}function _w(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Vt(n,[\"rename\",n,e.position.line,e.position.character,e.newName]),i=null;return r!==null&&(i={documentChanges:r}),{jsonrpc:Z,id:t.id,result:i}}function Rw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=pe.extname(e.textDocument.uri),i=Ln(e.textDocument.uri),o=on(r);$e.default.writeFileSync(o,i,{encoding:\"utf-8\"});let s=Ct(n,[\"documentSymbol\",o],t,!1);return $e.default.unlink(o,()=>null),s}function Sh(){let t={items:[{section:\"rescript.settings\"}]},e={jsonrpc:Z,id:ka,method:B.ConfigurationRequest.type.method,params:t};ne(e)}function bw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=pe.extname(e.textDocument.uri),i=Ln(e.textDocument.uri),o=on(r);$e.default.writeFileSync(o,i,{encoding:\"utf-8\"});let s=Ct(n,[\"semanticTokens\",o],t,!1);return $e.default.unlink(o,()=>null),s}function vw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Ln(e.textDocument.uri),i=on();$e.default.writeFileSync(i,r,{encoding:\"utf-8\"});let o=Ct(n,[\"completion\",n,e.position.line,e.position.character,i],t);return $e.default.unlink(i,()=>null),o}function ww(t){let e=t.params,n={jsonrpc:Z,id:t.id,result:e};if(e.documentation==null&&e.data!=null){let r=e.data,i=Vt(r.filePath,[\"completionResolve\",r.filePath,r.modulePath],!0);e.documentation={kind:\"markdown\",value:i}}return n}function Cw(t){let e=t.params,n=(0,Se.fileURLToPath)(e.textDocument.uri),r=Ln(e.textDocument.uri),i=pe.extname(e.textDocument.uri),o=on(i),s=[],a=Ah[e.textDocument.uri]??[],u=Eh(n)??[];[...a,...u].forEach(({range:A,codeAction:q})=>{fd(A,e.range)&&s.push(q)}),$e.default.writeFileSync(o,r,{encoding:\"utf-8\"});let p=Ct(n,[\"codeAction\",n,e.range.start.line,e.range.start.character,e.range.end.line,e.range.end.character,o],t);$e.default.unlink(o,()=>null);let{result:h}=p,y=h!=null&&Array.isArray(h)?[...s,...h]:s;return{jsonrpc:Z,id:t.id,result:y.length>0?y:null}}function Dw(t){let e={jsonrpc:Z,id:t.id,result:[]},n=t.params,r=(0,Se.fileURLToPath)(n.textDocument.uri),i=pe.extname(n.textDocument.uri);if(i!==Bt&&i!==Lr){let o={type:B.MessageType.Error,message:Not a ${Bt} or ${Lr} file. Cannot format it.};return[e,{jsonrpc:Z,method:\"window/showMessage\",params:o}]}else{let o=Ln(n.textDocument.uri),s=wt(r),u=(s!=null?Ve.get(s):null)?.bscBinaryLocation??null,p=ud(u,r,o);if(p.kind===\"success\"){let h=o.length,y=[{range:{start:{line:0,character:0},end:{line:h,character:h}},newText:p.result}];return[{jsonrpc:Z,id:t.id,result:y}]}else return[e]}}var Th=(t,e)=>{if(le.extensionConfiguration.incrementalTypechecking?.enable)return;let n=(0,Se.fileURLToPath)(t),r=pe.extname(n),i=on(r);$e.default.writeFileSync(i,e,{encoding:\"utf-8\"});let o=tw(t),s=Vt(n,[\"diagnosticSyntax\",i]),a={jsonrpc:Z,method:\"textDocument/publishDiagnostics\",params:{uri:t,diagnostics:[...s,...o]}};$e.default.unlink(i,()=>null),ne(a)};function Pw(t){let e=t.params,n=pe.extname(e.uri),r=(0,Se.fileURLToPath)(e.uri),i=wt(r);if(i===null){let q={type:B.MessageType.Error,message:\"Cannot locate project directory to generate the interface file.\"};return{jsonrpc:Z,method:\"window/showMessage\",params:q}}if(n!==Bt){let q={type:B.MessageType.Error,message:Not a ${Bt} file. Cannot create an interface for it.};return{jsonrpc:Z,method:\"window/showMessage\",params:q}}let o=r.split(i)[1],s=Wr(i);if(s.kind===\"error\"){let q={type:B.MessageType.Error,message:\"Error reading ReScript config file.\"};return{jsonrpc:Z,method:\"window/showMessage\",params:q}}let a=s.result,u=a.length>0?\"-\"+a:\"\",p=pe.join(pe.dirname(o),pe.basename(o,Bt)+u+zl),h=pe.join(i,er,p);if(!$e.default.existsSync(h)){let q={type:B.MessageType.Error,message:\"No compiled interface file found. Please compile your project first.\"};return{jsonrpc:Z,method:\"window/showMessage\",params:q}}let m=Ct(r,[\"createInterface\",r,h],t),A=typeof m.result==\"string\"?m.result:\"\";try{let q=eo(r,Lr);return $e.default.writeFileSync(q,A,{encoding:\"utf-8\"}),{jsonrpc:Z,id:t.id,result:{uri:Hr(q)}}}catch{return{jsonrpc:Z,id:t.id,error:{code:B.ErrorCodes.InternalError,message:\"Unable to create interface file.\"}}}}function Ew(t){let e=t.params,n=(0,Se.fileURLToPath)(e.uri),r=wt(n);if(r===null){let s={type:B.MessageType.Error,message:\"Cannot locate project directory.\"};return{jsonrpc:Z,method:\"window/showMessage\",params:s}}let i=ld(n,r);if(i.kind===\"error\"||!$e.default.existsSync(i.result)){let s=i.kind===\"success\"?No compiled file found. Expected it at: ${i.result}:\"No compiled file found. Please compile your project first.\",a={type:B.MessageType.Error,message:s};return{jsonrpc:Z,method:\"window/showMessage\",params:a}}return{jsonrpc:Z,id:t.id,result:{uri:Hr(i.result)}}}function kh(t){if(B.Message.isNotification(t)){if(!(!jc&&t.method!==\"exit\"))if(t.method===\"exit\")Ic?In.default.exit(0):In.default.exit(1);else if(t.method===Rn.DidOpenTextDocumentNotification.method){let e=t.params;aw(e.textDocument.uri,e.textDocument.text),Th(e.textDocument.uri,e.textDocument.text)}else if(t.method===Rn.DidChangeTextDocumentNotification.method){let e=t.params,n=pe.extname(e.textDocument.uri);if(n===Bt||n===Lr){let r=e.contentChanges;r.length===0||(uw(e.textDocument.uri,r[r.length-1].text),Th(e.textDocument.uri,r[r.length-1].text))}}else if(t.method===Rn.DidCloseTextDocumentNotification.method){let e=t.params;cw(e.textDocument.uri)}else t.method===Rn.DidChangeConfigurationNotification.type.method&&Sh()}else if(B.Message.isRequest(t))if(!jc&&t.method!==\"initialize\"){let e={jsonrpc:Z,id:t.id,error:{code:B.ErrorCodes.ServerNotInitialized,message:\"Server not initialized.\"}};ne(e)}else if(t.method===\"initialize\"){let e=t.params,n=e.initializationOptions?.extensionConfiguration;n!=null&&(le.extensionConfiguration=n);let r=e.initializationOptions?.extensionClientCapabilities;r!=null&&(Lc=r),Lc.supportsSnippetSyntax=!!e.capabilities.textDocument?.completion?.completionItem?.snippetSupport;let i={capabilities:{textDocumentSync:ti.TextDocumentSyncKind.Full,documentFormattingProvider:!0,hoverProvider:!0,definitionProvider:!0,typeDefinitionProvider:!0,referencesProvider:!0,codeActionProvider:!0,renameProvider:{prepareProvider:!0},documentSymbolProvider:!0,completionProvider:{triggerCharacters:[\".\",\">\",\"@\",\"~\",'\"',\"=\",\"(\"],resolveProvider:!0},semanticTokensProvider:{legend:{tokenTypes:[\"operator\",\"variable\",\"type\",\"modifier\",\"namespace\",\"enumMember\",\"property\",\"interface\"],tokenModifiers:[]},documentSelector:[{scheme:\"file\",language:\"rescript\"}],full:!0},inlayHintProvider:le.extensionConfiguration.inlayHints?.enable,codeLensProvider:le.extensionConfiguration.codeLens?{workDoneProgress:!1}:void 0,signatureHelpProvider:le.extensionConfiguration.signatureHelp?.enabled?{triggerCharacters:[\"(\"],retriggerCharacters:[\"=\",\",\"]}:void 0}},o={jsonrpc:Z,id:t.id,result:i};jc=!0,Oc=setInterval(()=>{Sh()},Yl),ne(o)}else if(t.method===\"initialized\"){let e={jsonrpc:Z,id:t.id,result:null};ne(e)}else if(t.method===\"shutdown\")if(Ic){let e={jsonrpc:Z,id:t.id,error:{code:B.ErrorCodes.InvalidRequest,message:\"Language server already received the shutdown request\"}};ne(e)}else{Ic=!0,sw(),Oc!=null&&clearInterval(Oc);let e={jsonrpc:Z,id:t.id,result:null};ne(e)}else if(t.method===B.HoverRequest.method)ne(lw(t));else if(t.method===B.DefinitionRequest.method)ne(pw(t));else if(t.method===B.TypeDefinitionRequest.method)ne(mw(t));else if(t.method===B.ReferencesRequest.method)ne(gw(t));else if(t.method===B.PrepareRenameRequest.method)ne(yw(t));else if(t.method===B.RenameRequest.method)ne(_w(t));else if(t.method===B.DocumentSymbolRequest.method)ne(Rw(t));else if(t.method===B.CompletionRequest.method)ne(vw(t));else if(t.method===B.CompletionResolveRequest.method)ne(ww(t));else if(t.method===B.SemanticTokensRequest.method)ne(bw(t));else if(t.method===B.CodeActionRequest.method)ne(Cw(t));else if(t.method===B.DocumentFormattingRequest.method)Dw(t).forEach(n=>ne(n));else if(t.method===Zv.method)ne(Pw(t));else if(t.method===ew.method)ne(Ew(t));else if(t.method===B.InlayHintRequest.method){let e=t.params;pe.extname(e.textDocument.uri)===Bt&&ne(dw(t))}else if(t.method===B.CodeLensRequest.method){let e=t.params;pe.extname(e.textDocument.uri)===Bt&&ne(fw(t))}else if(t.method===B.SignatureHelpRequest.method){let e=t.params;pe.extname(e.textDocument.uri)===Bt&&ne(hw(t))}else{let e={jsonrpc:Z,id:t.id,error:{code:B.ErrorCodes.InvalidRequest,message:\"Unrecognized editor request.\"}};ne(e)}else if(B.Message.isResponse(t)){if(t.id===ka){if(t.result!=null){let[e]=t.result;e!=null&&(le.extensionConfiguration=e)}}else if(t.result!=null&&t.result.title!=null&&t.result.title===Ta){let n=t.result.projectRootPath,r=qh(n);if(r!=null){let i=dd(r,n),o=Ve.get(n);o.bsbWatcherByEditor=i}}}}od(t=>{let e={type:B.MessageType.Warning,message:ReScript tooling: Internal error. Something broke. Here's the error message that you can report if you want:\n \n\nTypeError: s is not iterable\n at Th (/nix/store/smsf3d20n08h6h03b8hix19i6273nc14-rescript-language-server-1.62.0/lib/node_modules/@rescript/language-server/out/cli.js:42:10233)\n at pi.kh [as callback] (/nix/store/smsf3d20n08h6h03b8hix19i6273nc14-rescript-language-server-1.62.0/lib/node_modules/@rescript/language-server/out/cli.js:42:12321)\n at /nix/store/smsf3d20n08h6h03b8hix19i6273nc14-rescript-language-server-1.62.0/lib/node_modules/@rescript/language-server/out/cli.js:3:19579\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n\nNode.js v22.16.0\n"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the launch with NeoVim, nvim-lspconfig, and rescript-language-server 1.62.0 using the configuration in the issue, then inspect the reported stderr and exit status. Done means the language server remains running and initializes successfully instead of quitting with exit code 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100