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

[eval] Sys.stdout does not work when using compilation server #9359

Open
haxiomic opened this issue Apr 26, 2020 · 5 comments
Open

[eval] Sys.stdout does not work when using compilation server #9359

haxiomic opened this issue Apr 26, 2020 · 5 comments
Labels
Milestone

Comments

@haxiomic
Copy link
Member

haxiomic commented Apr 26, 2020

Reproduced with 4.0.5 and development branch

Main.hx

class Main {

	static function main() {
		trace('this will print correctly, but if using vscode build, the next line will not appear');
		Sys.stdout().writeString('this will not print if using vscode build task\n');

		// when uncommented, this will print all the previous stdout writes in the terminal of the compilation server, **not this program**
		// Sys.stdout().flush();
	}

}

build.hxml

--run Main

In vscode, run build task (Terminal -> Run build task)

When running a haxe file that uses the compilation server, i.e. haxe --run Main --connect 3000, writes to stdout and stderr will not be printed. If flush() is used the output is printed in the compilation-sever terminal rather than the main terminal.

It might seem weird to use --connect and --run together but this is the default behavior when using vscode so it's a common occurrence in that workflow (i.e if you use the vscode haxe build task this will happen)

Attached repro files, including some scripts to show the flush() weirdness

eval-stdout-bug.zip

@haxiomic haxiomic added the bug label Apr 26, 2020
@RealyUniqueName RealyUniqueName added this to the Bugs milestone Apr 29, 2020
@RealyUniqueName
Copy link
Member

I guess this may be pretty annoying for eval-based tools.
Probably also affects stdin and stderr.
@Simn do you think this should be fixed for 4.1?

@haxiomic
Copy link
Member Author

I'd argue it's worth resolving for 4.1 as it's pretty close to haxe hello world in vscode – I came across it while making an example for a newbie, simplest thing seemed to be to use the --run target so you can edit and see the program output interactively

@0b1kn00b
Copy link

I just came across this one. Any news? @Simn?

@Simn
Copy link
Member

Simn commented Mar 17, 2022

I don't understand how this is supposed to work. If anything uses --connect to speak to a different Haxe process via sockets, then anything like Sys.stdout() is always going to refer to the server's stdout, not the client's. IMO --connect is fundamentally flawed in this regard and unless I'm missing something, this cannot be fixed.

@Simn
Copy link
Member

Simn commented Mar 17, 2022

Well, actually, if I'm not hung up on the idea of referencing the actual stdout of the client, I suppose we could generalize com.print to something that ultimately behaves like stdout.

Simn added a commit that referenced this issue Mar 17, 2022
Simn added a commit that referenced this issue Mar 20, 2022
* reorganize compiler/server frontend

* try some piping

see #9359

* clean up some more

* try to get subprocess piping right

* actually we need the shell...

* hold back on pipe changes because this isn't working right

* move some more stuff around

* a little more

* try to dodge for now

* try something

* some more cleanup

* $currentyear

skip ci
@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants