codefori / vscode-rpgle

RPGLE language tools for VS Code
MIT License
39 stars 20 forks source link

RPGLE Language client failed now no more functionality from extension. #246

Closed m-tyler closed 1 year ago

m-tyler commented 1 year ago

I just had the RPGLE Language client fail (sorry I don't have logs for the error). Once it fails nothing in the extension seems to function.

Is there a VSCode method of restarting without completing restarting the VSCode session?

worksofliam commented 1 year ago

No. Requires a full restart I'm afraid. I should change that.

m-tyler commented 1 year ago

I have seen similar error logs as in #244.

worksofliam commented 1 year ago

@m-tyler are you able to share them?

m-tyler commented 1 year ago

not at the moment. It fails at unexpected times. But when I notice it again I will grab the details and post here.

m-tyler commented 1 year ago

Okay here is a log. It happened whilst opening a member. RPGLE_issue_246.txt

worksofliam commented 1 year ago

Okay so here's what I can tell:

m-tyler commented 1 year ago

This just happened without using a workspace.

Project Mode enabled: false
[Error - 9:49:44 AM] Request textDocument/hover failed.
  Message: Request memberResolve failed with message: (SSH) Channel open failure: open failed
  Code: -32603 
[Error - 9:49:46 AM] Request textDocument/documentSymbol failed.
  Message: Request memberResolve failed with message: (SSH) Channel open failure: open failed
  Code: -32603 

2023-08-23 09:49:44.837 [error] [halcyontechltd.vscode-rpgle] provider FAILED
2023-08-23 09:49:44.838 [error] Error: Request memberResolve failed with message: (SSH) Channel open failure: open failed
    at c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52171
    at c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52465
    at Immediate.<anonymous> (c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52830)
    at process.processImmediate (node:internal/timers:466:21)
2023-08-23 09:49:46.601 [error] [halcyontechltd.vscode-rpgle] provider FAILED
2023-08-23 09:49:46.602 [error] Error: Request memberResolve failed with message: (SSH) Channel open failure: open failed
    at c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52171
    at c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52465
    at Immediate.<anonymous> (c:\Users\matt.tyler\.vscode\extensions\halcyontechltd.vscode-rpgle-0.21.1\out\extension.js:1:52830)
    at process.processImmediate (node:internal/timers:466:21)
worksofliam commented 1 year ago

@m-tyler Were you connected when you got that error? I assume it was from a member?

m-tyler commented 1 year ago

Yes. Yes.

worksofliam commented 1 year ago

@m-tyler How large is this code?

You don't have the share the entire file, but any chance you can share solely the copy and include directives?

m-tyler commented 1 year ago

Give me a little time to get those to you. I needed to restart VSCode and now its not erroring on the source member I thought it was before. I might have opened another before the one I linked to the RPGLE language server error.

I need to try to recreate the problem.

m-tyler commented 1 year ago

More information. I included other output channels. RPGLE_issue_246-2.md

m-tyler commented 1 year ago

Also, I noticed the section like for f in ...; do if [ -f $f ]; then echo $f; break; fi; done. The follow is the results from QP2TERM and QSHELL.

 > for f in /QSYS.LIB/PGMT.LIB/QCPYSRC.FILE/APIERRORDS.MBR; do if [ -f $f ]; then echo $f; break; fi; done         
   $                                                                                                               
 > for f in /QSYS.LIB/WFISRC.LIB/QCPYSRC.FILE/APIERRORDS.MBR; do if [ -f $f ]; then echo $f; break; fi; done       
   $                                                                                                               
 > for f in /WIASP/QSYS.LIB/WFISRC.LIB/QCPYSRC.FILE/APIERRORDS.MBR; do if [ -f $f ]; then echo $f; break; fi; done 
   /WIASP/QSYS.LIB/WFISRC.LIB/QCPYSRC.FILE/APIERRORDS.MBR                                                          
   $                                                                                                               

The only one that succeeds is the one with the WIASP reference.

m-tyler commented 1 year ago

For your consideration, this statement might be a little slower to complete than the shell code but it far more accurate.

;select * from SYSPARTITIONSTAT
where 
( 1=2
or TABLE_NAME = '${SRCFILE}' and TABLE_PARTITION = '${SRCMEMBER}' // Repeat this line for each distinct FILE/MEMBER combo
) 
and TABLE_SCHEMA in ( ${LIBLIST} )
worksofliam commented 1 year ago

@m-tyler thanks! You're using an ASP.. I will test with that further.

It's actually a good idea to switch to using SQL (thanks for your lovely example).. I will consider it this week.

Nonetheless, it shouldn't be crashing. I will look into improving the handling.

worksofliam commented 1 year ago

I've built this CL that resolves members very fast and even supports the ASPs correctly. I am trying to decide what the best and most performant way of resolving this is.

PGM PARM(&SRCPF &NAME)
  DCL VAR(&SRCPF) TYPE(*CHAR) LEN(10)
  DCL VAR(&NAME) TYPE(*CHAR) LEN(10)
  DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
  DCL VAR(&EXT) TYPE(*CHAR) LEN(10)
  DCL VAR(&MSG) TYPE(*CHAR) LEN(50)

  RTVMBRD FILE(*LIBL/&SRCPF) MBR(&NAME) RTNLIB(&LIB) SRCTYPE(&EXT)
  CHGVAR VAR(&MSG) VALUE( +
    &LIB *TCAT '/' *TCAT +
    &SRCPF *TCAT '/' *TCAT +
    &NAME *TCAT '.' *TCAT +
    &EXT +
  )
  CALLPRC PRC('printf') PARM(&MSG)
ENDPGM
m-tyler commented 1 year ago

When I run this program call rslvmbrlib (qcpysrc hspecle) I get error message Member HSPECLE file QCPYSRC in library PGMT not found.

Job log recording of CL code 800 - RTVMBRD FILE(*LIBL/QCPYSRC) MBR(HSPECLE) RTNLIB(&LIB) SRCTYPE(&EXT)

worksofliam commented 1 year ago

That would indicate it's not on your library list?

m-tyler commented 1 year ago

The member is on the *LIBL but not in the source file found first which is in LIB PGMT.

QCPYSYC in my LIBL (obtained by this SQL `select from QSYS/QADBXREF XR inner join QSYS2.LIBRARY_LIST_INFO LL on LL.SYSTEM_SCHEMA_NAME = XR.DBXLIB where DBXFIL = 'QCPYSRC' order by LL.ORDINAL_POSITION`)

DBXFIL DBXLIB
QCPYSRC PGMT
QCPYSRC WFIMODULES
QCPYSRC WSBINTG
QCPYSRC WSBQUAL
QCPYSRC WSBSRC
QCPYSRC DEVQUAL
QCPYSRC DTSINTG
QCPYSRC DTSQUAL
QCPYSRC DTSUSER
QCPYSRC DTSCNTRL
QCPYSRC WFIINTG
QCPYSRC WFIQUAL
QCPYSRC WFIOBJ
QCPYSRC WFISRC

image

m-tyler commented 1 year ago

This SQL is the most accurate I can think of but it performs poorly the first few times. After about 3-5 quick executions it responds very fast.

;select * from QSYS2.SYSPARTITIONSTAT PS
inner join QSYS2.LIBRARY_LIST_INFO LL on LL.SYSTEM_SCHEMA_NAME= PS.SYSTEM_TABLE_SCHEMA and LL."TYPE"='USER'
where 
( 
1=2
or TABLE_NAME = '${SRCFILE}' and TABLE_PARTITION = '${SRCMEMBER}' -- Repeat this line for each distinct FILE/MEMBER combo
) 
order by LL.ORDINAL_POSITION
limit 1

There must be another tool IBM uses in RDi to search for a member as I can quick open this member in RDi without needing to supply the specific library and it finds the one highest up on the *LIBL.

In one other post I had posted the idea about performing a ghost compile just to get the event file member references but the flaw in that idea is the event file is created in the library of the compiled object. This might mean creating the ghost object in ILEDITOR then removing the object.

worksofliam commented 1 year ago

How are we not getting the same results with that CL?

I have it scanning the library list pretty well and even have test cases for it.

m-tyler commented 1 year ago

Side note, adding our IASP name to the shell string does end up resolving the members correctly but it is not the reason for the server crashing.

Fetching file from server: member:/WFISRC/QCPYSRC/KRN05CRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05CRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DATEUTL.DS.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DATEUTL.DS.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DATEUTL.DS.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05ERGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DSPGMINF4.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL000RGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DSPGMINF4.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05FRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05FRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL000RGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL000RGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05FRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05FRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL000RGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/FKEYSLE.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP55XRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP03BPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP55XRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/TLKMSGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/APIERRORDS.rpgleinc
Validating file from server: member:/WFISRC/VSCODE/RPGLINT.JSON
Fetching file from server: member:/WFISRC/QCPYSRC/TLKMSGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/TLKMSGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/TLKMSGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/TLKMSGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP03BPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP03BPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DATEUTL.PR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL80APR.rpgleinc
Validating file from server: member:/WFISRC/VSCODE/RPGLINT.JSON
Validating file from server: member:/WFISRC/VSCODE/RPGLINT.JSON
Fetching file from server: member:/WFISRC/QCPYSRC/DATEUTL.PR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/DSPFINFDS.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10HCLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10ACLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10HCLPR.rpgleinc
Fetching file from server: member:/WFIQUAL/QCPYSRC/PRP00APR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10HCLPR.rpgleinc
Validating file from server: member:/WFISRC/VSCODE/RPGLINT.JSON
Fetching file from server: member:/WFISRC/QCPYSRC/EML10ACLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10ACLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/EML10ACLPR.rpgleinc
Fetching file from server: member:/WFIQUAL/QCPYSRC/PRP00APR.rpgleinc
Fetching file from server: member:/WFIQUAL/QCPYSRC/PRP00APR.rpgleinc
Fetching file from server: member:/WFIQUAL/QCPYSRC/PRP00APR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL25ACLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL10ARGPR.rpgleinc
Fetching file from server: member:/WFIQUAL/QCPYSRC/PRP00APR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL25ACLPR.rpgleinc
Validating file from server: member:/WFIQUAL/VSCODE/RPGLINT.JSON
Fetching file from server: member:/WFISRC/QCPYSRC/PRP06YRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP06YRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP06YRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP06YRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL25ACLPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL10ARGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL10ARGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL10ARGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL10ARGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/MSGTOOLSCL.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/QCMDEXCPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/HSPECLE.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/QCMDEXCPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/QCMDEXCPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/QCMDEXCPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/MSGTOOLSCL.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/QCMDEXCPR.rpgleinc
Fetching file from server: member:/WFISRC/QRPGSRC/PRPEMPDS.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP01SPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/HSPECLE.rpgleinc
[Error - 8:54:59 AM] Request textDocument/documentSymbol failed.
  Message: Request memberResolve failed with message: (SSH) Channel open failure: open failed
  Code: -32603 
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05BRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/KRN05HRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/PRP11FRGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/F4DATE.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL44ARGPR.rpgleinc
Fetching file from server: member:/WFISRC/QCPYSRC/UTL18ECLPR.rpgleinc

At first I thought that I was runn the program incorrectly because of the printf function but I ran it using this in QSHELL, system 'CALL RSLVMBRLIB (QCPYSRC hspecle) '. It never returns. I modified the CL code to monitor for any error and it 'completes' but when run in QSHELL I have to press an extra enter key to get the shell prompt back.

Reading the command help for RTVMBRD,

     All libraries in the library list for the current thread are
     searched until the first match is found.                    

When searching for a member in my library its working as I and you expect.

m-tyler commented 1 year ago

BTW, we are at 7.5, I wonder if there is a change to the command then.

worksofliam commented 1 year ago

I wonder if Channel open failure: open failed is happen due to the sheer amount of requests being sent to the server.

m-tyler commented 1 year ago

Maybe, there needs to be a resolveMembers that accepts a list of members as well as the library list.

worksofliam commented 1 year ago

@m-tyler The likeliness of that happening in the short term is low. I just tested with a member that had 20 or so includes and was not able to recreate this issue.

worksofliam commented 1 year ago

I am having good luck with the PR I have created which has a brand new, iASP compliant, member resolve using the RTVMBRD CL command.

You can check it out here, but won't be available to this extension until we've done another release.

m-tyler commented 1 year ago

I can wait for that update as I recreate an situation where the language server is crashing. It seems to be only when you open several members from the filter, quickly.

If I reload VSC using the reload command, the product reconnects and processes each open member at a different pace, the language server does not crash. If I open the same members more slowly, say double click, wait for outline to populate, open another, repeat, the language server does not crash.

With members open, reload VSC, open filter where you originally selected to open members, double click on same members quickly and the language server errors or crashes.

I will attempt to focus on reducing my open members at one time and how quickly I open them to reduce the number of SSH connections made for cross referencing.

worksofliam commented 1 year ago

Ok, that I can recreate. I can add better handlers for this.

image
worksofliam commented 1 year ago

@m-tyler 0.21.2 is being release right now which will hold back the spamming of requests to the server! Added a neat queue system which really (really!) helps things in this area.

worksofliam commented 1 year ago

ASPs will be next, but will be another issue. Please close this if/when you're happy that the crash no longer happens.

m-tyler commented 1 year ago

You are not going to like me after this.

RPGLE_issue_246-3.md

If there are no others reporting this issue then I would suggest putting this on the back burner for a little bit as I know how to keep it from happening from the point of opening members.

The log attached is from the development version (0.21.2) of the extension, not the packaged version (0.21.2) so that the line errors are clearer.

If I have many (3 or more) open members upon start up and I tab to each one to make it build the outlines, I can get Vs Code to present the error.

I asked another person about this and one suggestion given was possible firewall restrictions on the number of concurrent connections.

Thanks for working on this for me.

worksofliam commented 1 year ago

Will look into this further.

There are no additional connects. Just one, but many channels (ssh term)

worksofliam commented 1 year ago

@m-tyler I am trying really hard to create your scenario by having a bunch of tabs already open when I launch VS Code, but I am having 0 luck. Please try the release version, and then if no luck, I'd love to meet with you to diagnose further. Thank you!

m-tyler commented 1 year ago

Version 0.21.3 seems to be solving the issues I have seen. With an added benefit of showing an odd copy book reference in the RPGLE Langauge server output channel.

The reference in the output channel

Validating file from server: member:/QSYSINC/QRPGLESRC/QWCATTR%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Define%20API%20format..rpgleinc

What the production source looks like image Apparently IBM puts a line length limit in copy book statements.

I say this issue is resolved for me.

m-tyler commented 1 year ago

Try as I might, I cannot get the RPGLE Language server to fail any more. This last update seems to have fixed the problem reported. I'll close this now.

THANKS! Matt