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

ttsc -watch crashing when regenerating files #92

Open
oaosman84 opened this issue May 9, 2020 · 9 comments
Open

ttsc -watch crashing when regenerating files #92

oaosman84 opened this issue May 9, 2020 · 9 comments

Comments

@oaosman84
Copy link

Hey,
We use ttsc -watch, and when I regenerate some files (using Apollo's code type generator), the compiler crashes. Though the stack trace is coming from typescript, this doesn't seem to happen with normal tsc - watch.

[11:25:24 AM] File change detected. Starting incremental compilation...


/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:2121
                fail("Expected " + a + " <= " + b);
                ^
Error: Debug Failure. Expected 2511 <= 2502
    at Object.assertLessThanOrEqual (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:2121:17)
    at Object.createFileDiagnostic (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:16725:22)
    at createDiagnosticForNodeInSourceFile (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:10590:19)
    at Object.createDiagnosticForNode (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:10580:16)
    at error (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:33795:22)
    at resolveExternalModule (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:35446:25)
    at resolveExternalModuleNameWorker (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:35363:19)
    at resolveExternalModuleName (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:35358:20)
    at getSymbolAtLocation (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:63620:32)
    at Object.getSymbolAtLocation (/Users/osmanosman/Developer/apps/packages/common/node_modules/typescript/lib/typescript.js:33312:31)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@cevek
Copy link
Owner

cevek commented Sep 7, 2020

@oaosman84 Do you have any repro project?

@trungda
Copy link

trungda commented Oct 16, 2020

I am encountering the same issue

@Val-istar-Guo
Copy link

Val-istar-Guo commented Nov 13, 2020

ttsc --watch will throw error,But tsc not throw

same issue:

           : ts.skipTrivia(sourceFile.text, errorNode.pos);
                                       ^
TypeError: Cannot read property 'text' of undefined
    at getErrorSpanForNode (/report/node_modules/typescript/lib/typescript.js:13660:40)
    at createDiagnosticForNodeInSourceFile (/report/node_modules/typescript/lib/typescript.js:13564:20)
    at Object.createDiagnosticForNode (/report/node_modules/typescript/lib/typescript.js:13555:16)
    at error (/Users/shein/report/node_modules/typescript/lib/typescript.js:43205:22)
    at resolveExternalModule (/report/node_modules/typescript/lib/typescript.js:45212:25)
    at resolveExternalModuleNameWorker (/report/node_modules/typescript/lib/typescript.js:45129:19)
    at resolveExternalModuleName (/report/node_modules/typescript/lib/typescript.js:45124:20)
    at checkImportDeclaration (/report/node_modules/typescript/lib/typescript.js:74645:49)
    at checkSourceElementWorker (/report/node_modules/typescript/lib/typescript.js:75078:28)
    at checkSourceElement (/report/node_modules/typescript/lib/typescript.js:74911:17)

@nonara
Copy link
Contributor

nonara commented Nov 15, 2020

Not sure what's happening here, but here's my 2 cents from my own experience and reports from others.

Generally these types of errors come from modifying nodes incorrectly. In other words not using the API - ie. directly modifying properties, replacing nodes by assignment, etc. We can sometimes get away with hacks like that during a one-shot transformation, but watch mode actively maintains the AST and all of the trivia and diagnostics associated. Circumventing the API causes it to break down as its references are mismatched.

If either of you can create a minimal reproduction, I'd be happy to have a look.

@Val-istar-Guo
Copy link

@nonara I found my problem because of the use of typescript-transform-paths@2 version.typescript-transform-paths@1 is running normally, it should be a typescript-transform-paths problem.

LeDDGroup/typescript-transform-paths#72

@nonara
Copy link
Contributor

nonara commented Nov 17, 2020

@Val-istar-Guo Haha. Yep, that'd do it then. We're using a workaround which directly replaces a node due to a TS compiler issue. Really hoping TS fixes the upstream issue so I can close that. I'm monitoring closely. If TS doesn't fix it by v4.2.0, I'll find another way or do a PR on TS.

Meanwhile, I suggest using v1 for now and follow that issue.

@nonara
Copy link
Contributor

nonara commented Nov 17, 2020

@Val-istar-Guo I had some time to dig into the new compiler API, and I believe the issue should be resolved. If you have a chance to try v2.0.3, I'd appreciate it if you let me know if it works for you!

@Val-istar-Guo
Copy link

@nonara Unfortunately, the error did not go away

  • "typescript-transform-paths": "^2.0.3"
  • "ttypescript": "^1.5.12",
  • "typescript": "^4.1.2",
  • "typescript-nestjs-swagger-plugin": "^1.1.0",
***/node_modules/typescript/lib/typescript.js:14332
 :ts.skipTrivia(sourceFile.text, errorNode.pos);

TypeError: Cannot read property 'text' of undefined

Operating procedures

  • ttsc --watch
  • change some ts file that be watched
  • The error throw

@nonara
Copy link
Contributor

nonara commented Nov 22, 2020

@Val-istar-Guo thanks for following up. There may not be anything that we can do until TS fixes the upstream. Would you mind filing an issue with the problem and repro steps on the GH issues for typescript-transform-paths?

When you do, I'll look into it and you can track what's going on there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants