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

Debug Failure. False expression: Expected isNewFile for (only) new files #27867

Closed
amcasey opened this issue Oct 12, 2018 · 15 comments
Closed

Debug Failure. False expression: Expected isNewFile for (only) new files #27867

amcasey opened this issue Oct 12, 2018 · 15 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Source: Telemetry The issue relates to the telemetry in editors

Comments

@amcasey
Copy link
Member

amcasey commented Oct 12, 2018

We have occurrences from 3.0.0-dev to 3.2.0-dev. Here's a stack from 3.1.3:

Error processing request. Debug Failure. False expression: Expected isNewFile for (only) new files
Verbose Debug Information: {"isNewFile":false,"hasScriptInfo":false}
Error: Debug Failure. False expression: Expected isNewFile for (only) new files
Verbose Debug Information: {"isNewFile":false,"hasScriptInfo":false}
    at mapTextChangesToCodeEdits (tsserver.js:123151:22)
    at IOSession.Session.mapTextChangeToCodeEdit (tsserver.js:122984:24)
    at tsserver.js:122981:73
    at Array.map (<anonymous>)
    at IOSession.Session.mapTextChangesToCodeEdits (tsserver.js:122981:36)
    at IOSession.Session.mapCodeFixAction (tsserver.js:122977:84)
    at tsserver.js:122930:96
    at Array.map (<anonymous>)
    at IOSession.Session.getCodeFixes (tsserver.js:122930:55)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:121789:61)
    at tsserver.js:123086:88
    at IOSession.Session.executeWithRequestId (tsserver.js:123077:28)
    at IOSession.Session.executeCommand (tsserver.js:123086:33)
    at IOSession.Session.onMessage (tsserver.js:123106:35)
    at Interface.<anonymous> (tsserver.js:124369:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)
@amcasey amcasey added Bug A bug in TypeScript Source: Telemetry The issue relates to the telemetry in editors labels Oct 12, 2018
@amcasey amcasey assigned ghost Oct 12, 2018
@ghost
Copy link

ghost commented Oct 12, 2018

Is that the wrong stack trace? The diagnostic "Expected isNewFile for (only) new files" should only happen in mapTextChangesToCodeEdits, not tryResuseStructureFromOldProgram.

@amcasey
Copy link
Member Author

amcasey commented Oct 12, 2018

Quite possibly - I've been looking at several. Let me confirm.

@amcasey
Copy link
Member Author

amcasey commented Oct 12, 2018

Fixed - sorry about that.

@Hexcles
Copy link

Hexcles commented Oct 17, 2018

I'm seeing this error from tsserver in my editor (Vim with YCM) (with almost the same stacktrace) when I have import fs = require('fs'); style import in my Node project (target=es2017, everything else is the default). Switching to const fs = require('fs') makes the error go away.

@Hexcles
Copy link

Hexcles commented Oct 17, 2018

I just found out it only happened when I used import = require style import on a module without type annotations, but this still looks like a bug -- it shouldn't crash the server. tsc is still able to tell me to try npm install @types/..., among other errors.

@ghost
Copy link

ghost commented Oct 30, 2018

@Hexcles I'm not able to reproduce this crash using that repro in typescript@next. I'm testing in a directory that consists of just these files:
a.ts:

import fs = require('fs');

tsconfig.json:

{
    "compilerOptions": {
        "target": "es2017"
    }
}

I've also tested with @types/node installed but still didn't see a crash.
I assume you're also seeing a diagnostic Import assignment cannot be used when targeting ECMAScript modules. given those compiler options.

@Hexcles
Copy link

Hexcles commented Nov 15, 2018

Looking at my tsconfig.json again there's also module: "commonjs" which prevents the warning about the import assignment.

However, I can't reproduce the issue any more, either. I'm not sure if my tsc installation was updated recently. Looks like you initially found the issue from telemetry so you might be able to look at stats to see if the problem has indeed disappeared in recent versions.

@ghost ghost assigned sheetalkamat and unassigned ghost Nov 15, 2018
@tim-phillips
Copy link

I get the same error on 3.3.0-dev (using YouCompleteMe):

Debug Failure. Expected isNewFile for (only) new files. {"isNewFile":false,"hasScriptInfo":false}

Error: Debug Failure. Expected isNewFile for (only) new files. {"isNewFile":false,"hasScriptInfo":false}
    at IOSession.Session.mapTextChangeToCodeEdit (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125567:30)
    at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125559:73
    at Array.map (<anonymous>)
    at IOSession.Session.mapTextChangesToCodeEdits (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125559:36)
    at IOSession.Session.mapCodeFixAction (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125555:84)
    at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125508:96
    at Array.map (<anonymous>)
    at IOSession.Session.getCodeFixes (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125508:55)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:124313:61)
    at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125676:88
    at IOSession.Session.executeWithRequestId (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125667:28)
    at IOSession.Session.executeCommand (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125676:33)
    at IOSession.Session.onMessage (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125698:35)
    at Interface.<anonymous> (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:126958:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

I don't get the error when there is no import statement, but as soon as I add import React from 'react' or const react = require('react') then it errors.

@tim-phillips
Copy link

I installed Visual Studio Code and it somehow fixed this issue for me in vim/ycm.

@sheetalkamat
Copy link
Member

Closing this as it seems fixed in recent build. @amcasey please reopen if this repros in newer builds.

@amcasey
Copy link
Member Author

amcasey commented Jan 22, 2019

I see recent hits for getEditsForFileRename, getEditsForRefactor, and getCodeFixes in 3.3.0-dev, 3.3.0-dev.20190101, and 3.3.0-dev.20190108.

@amcasey amcasey reopened this Jan 22, 2019
@sheetalkamat
Copy link
Member

sheetalkamat commented Jan 22, 2019

@amcasey I think #26280 should also fix it. So if any reports of this after 3.3.0-dev.20190109 would qualify for reinvestigation.

@sheetalkamat sheetalkamat added the Fixed A PR has been merged for this issue label Jan 22, 2019
@adammenges
Copy link

I currently see this in Atom with atom-typescript:

screen shot 2019-02-09 at 5 02 20 pm

⇒  tsc --version
Version 3.3.3

@sheetalkamat
Copy link
Member

@adammenges Can you please share the tssever log of the issue? Thanks.

@sheetalkamat
Copy link
Member

@adammenges Please provide complete tsserver log for us to be able to investigate this futher. Thanks. We will open this again when we have more information. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Source: Telemetry The issue relates to the telemetry in editors
Projects
None yet
Development

No branches or pull requests

7 participants