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

ts.TypeScriptNoContentAvailableException on compile #190

Closed
axelnerlich opened this issue Jul 12, 2017 · 14 comments
Closed

ts.TypeScriptNoContentAvailableException on compile #190

axelnerlich opened this issue Jul 12, 2017 · 14 comments
Milestone

Comments

@axelnerlich
Copy link

Starting from an empty project, I can compile TS code without problem.
As soon as I add types (under node_modules/@types) using npm, I get the following error message when saving a TS file:

Errors occurred during the build.
Errors running builder 'TypeScript Builder' on project 'TypescriptProject'.
Error while compiling with tsserver
java.util.concurrent.ExecutionException: ts.TypeScriptNoContentAvailableException: No content available.
Error while compiling with tsserver
java.util.concurrent.ExecutionException: ts.TypeScriptNoContentAvailableException: No content available.

For info: I have node.js v6.11.0 installed on my Windows computer. The error always occurs on my computer and occasionally occurs on my colleague's machine
TypeScriptNoContentAvailableException.zip

.

@angelozerr
Copy link
Owner

It's the TypeScript tsserver which throw this error. I think this error should be silent and not display an error when tsserver throws it.

@axelnerlich
Copy link
Author

How about the following code change in the IDETypeScriptProject class (two lines added):
@OverRide
public void compileWithTsserver(List updatedTsFiles, List removedTsFiles, IProgressMonitor monitor)
throws TypeScriptException {
try {
List tsFilesToCompile = new ArrayList<>();
// Collect ts files to compile by using tsserver to retrieve
// dependencies files.
// It works only if tsconfig.json declares "compileOnSave: true".
if (collectTsFilesToCompile(updatedTsFiles, getClient(), tsFilesToCompile, false, monitor)) {
return;
}

		// Compile ts files with tsserver.
		if (compileTsFiles(tsFilesToCompile, getClient(), monitor)) {
			return;
		}
		if (removedTsFiles.size() > 0) {
			// ts files was removed, how to get referenced files which must
			// be recompiled (with errors)?
		}
  } catch (TypeScriptNoContentAvailableException e) {
                   // Ignore "No content available" error.
            } catch (TypeScriptException e) {
		throw e;
	} catch (Exception e) {
		throw new TypeScriptException(e);
	}
}

@axelnerlich
Copy link
Author

But can we just ignore the exception really? Cause maybe there is really no content that is sent to the tsserver. The compilation then still fails (with or without error message).
I hope the problem is reproducible with the demo project I have attached to the issue.
I really would like to use the Typescript IDE plugin because it seems quite cool.

@stenzengel
Copy link

Same problem for me. Even with axelnerlich's small project: Sometimes I get a TypeScriptNoContentAvailableException when saving. Looks a bit terrifying...

It seems to be a timing problem, because the exception appears more frequently, when saving is done directly after editing.

Apart from this error, I'm really impressed by all the new features! Great work, anglozerr!

@danielvanmil
Copy link

danielvanmil commented Jul 14, 2017

Same here, would be nice when fixed as the popup only appears at some arbitrary moments after a save, but is very annoying. As mentioned, the error from the tsserver could be valid and the question is why this error is returned?

Keep up the good work!

@angelozerr
Copy link
Owner

I must study more cases whrn tsserver throws this error. If i remember it throws this error when you try tout savez a TS file which is excluded by tsconfih.JSON . it seems that there are more cases.

@stenzengel
Copy link

@angelozerr:
Do you think that this bug can be resolved soon? Can you reproduce the behaviour?

I have thoroughly tested your plugin for almost a week now. Everything looks very, very good, but this bug is really annoying.

I will show your plugin tomorrow in a presentation to my collegues. We would like to decide on the usage of your plugin, but this bug could be a showstopper. If I could at least tell them, that there is a good chance that this bug will be fixed...

@angelozerr
Copy link
Owner

I m on Holliday this week. I will try to fix it next week by ignoring this error everytime or on dôme cases if i understand cases when tsserver throws this error.

@stenzengel
Copy link

@angelozerr:
Thank you!

An observation: It seems to be a timing problem, because the exception appears more frequently, when saving is done directly after editing. If I wait some seconds after editing, the error is less frequent.

@angelozerr
Copy link
Owner

Ok I have decided to ignore the TypeScriptNoContentAvailableException exception with 8fa29dc

@axelnerlich I have used your project from TypeScriptNoContentAvailableException.zip and problem comes from tsserver. The first time when I save new_file.ts, the tsserver compileOnSaveEmitFile is executed to know while files must be compiled

{
	"command": "compileOnSaveEmitFile",
	"arguments": {
		"forced": true,
		"file": "C:/Users/azerr/WS2/TypescriptProject/new_file.ts"
	},
	"seq": 1248,
	"type": "request"
}

An it returns *.d.ts files:

{
	"seq": 0,
	"type": "response",
	"command": "compileOnSaveAffectedFileList",
	"request_seq": 1247,
	"success": true,
	"body": [
		{
			"projectFileName": "C:/Users/azerr/WS2/TypescriptProject/tsconfig.json",
			"fileNames": [
				"C:/Users/azerr/WS2/TypescriptProject/new_file.ts",
				"C:/Users/azerr/WS2/TypescriptProject/node_modules/@types/jquery/index.d.ts",
				"C:/Users/azerr/WS2/TypescriptProject/node_modules/@types/node/index.d.ts",
				"C:/Users/azerr/WS2/TypescriptProject/node_modules/parse5/lib/index.d.ts",
				"C:/Users/azerr/WS2/TypescriptProject/node_modules/@types/tough-cookie/index.d.ts",
				"C:/Users/azerr/WS2/TypescriptProject/node_modules/@types/jsdom/index.d.ts"
			],
			"projectUsesOutFile": false
		}
	]
}

So after node_modules/@types/jquery/index.d.ts are compiled and the TypeScriptNoContentAvailableException is thrown (it's normal because we cannot compile this file).

The second time, when I save new_file.ts, I have

{
	"seq": 0,
	"type": "response",
	"command": "compileOnSaveAffectedFileList",
	"request_seq": 1247,
	"success": true,
	"body": [
		{
			"projectFileName": "C:/Users/azerr/WS2/TypescriptProject/tsconfig.json",
			"fileNames": [
				"C:/Users/azerr/WS2/TypescriptProject/new_file.ts"			],
			"projectUsesOutFile": false
		}
	]
}

So we have not the exception. Is it a bug with TypeScript? The popup is not usable, so I have decided to ignore the error. If some guy find a better solution (like mark with warn file which cannot be compiled), any suggestion are welcome!

@angelozerr angelozerr added this to the 1.4.0 milestone Jul 25, 2017
@angelozerr
Copy link
Owner

Once job https://opensagres.ci.cloudbees.com/job/typescript.java/423/ will be finished, you will able to install 1.4.0-SNAPSHOT https://github.com/angelozerr/typescript.java/wiki/Installation-Update-Site

@angelozerr
Copy link
Owner

Guys, I close this issue, if you have again problem, please reopen the issue or create new one. Thanks!

@stenzengel
Copy link

@angelozerr
Thanks for your quick reaction. The bugfix works for us. :-)

Just for curiosity: Does your plugin initiate the compilation for the files received in the compileOnSaveAffectedFileList response? If yes, why can't you filter away the 'index.d.ts' files when initiatiating the compilation?

@angelozerr
Copy link
Owner

Just for curiosity: Does your plugin initiate the compilation for the files received in the compileOnSaveAffectedFileList response? If yes, why can't you filter away the 'index.d.ts' files when initiatiating the compilation?

Good catch! I have implemented your idea with 566e841

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

No branches or pull requests

4 participants