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

Awaiting stderr results in script hanging, sometimes #5621

Closed
HarryPeach opened this issue May 19, 2020 · 8 comments
Closed

Awaiting stderr results in script hanging, sometimes #5621

HarryPeach opened this issue May 19, 2020 · 8 comments
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@HarryPeach
Copy link

Hi, I'm writing a library for a terminal spinner, and sometimes the script will hang after writing.
I think I've narrowed it down to the Deno.write calls, as there seems to be some async issues going on.

The solution to a similar issue in #5515 was to await all write calls, which is what I've done but the error still persists.

The following code:

const kia = new Kia("test");
await kia.start();
await sleep(3000);
await kia.stop();

console.log("All done");

Results in this output and hang:
image

All the calls to Deno.write look like this:

export async function writeLine(
	rid: number,
	encoder: TextEncoder,
	text: string,
	indent?: number
) {
	await Deno.write(
		rid,
		encoder.encode(`\r${indent ? ESC + indent + "C" : ""}${text}`)
	);
}

And all calls are awaited

await writeLine(
			this.options.resource,
			this.textEncoder,
			`${flair} ${text}`,
			this.options.indent
		);

(the full code is at my Kia repo if you need more context)

@cknight
Copy link
Contributor

cknight commented May 19, 2020

Can you post a link to your repo? There's not enough context here to help you effectively.

@HarryPeach
Copy link
Author

@bartlomieju
Copy link
Member

Most likely same problem as in #4789

@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels May 21, 2020
@HarryPeach
Copy link
Author

I've tested and this issue still appears on deno version prior to 0.41.0, so it may not be the same issue

@bartlomieju
Copy link
Member

bartlomieju commented May 21, 2020

@HarryPeach have you taken into account that Deno.write() might write less bytes than the buffer you give? Ie. you might need to call Deno.write() multiple times on the same buffer but with different offset. Can you try replacing Deno.write() calls with Deno.writeAll() to see if that helps?

@HarryPeach
Copy link
Author

Replacing all instances of Deno.write() with Deno.writeAll() doesn't seem to fix it

@bnoordhuis
Copy link
Contributor

@HarryPeach Do you have a small standalone test case I can try locally? I want to track this down but I need something minimal.

@crowlKats
Copy link
Member

I have run the provided example and I cannot reproduce this, and since there has not been a reply from author since nearly 3 years to provide further information, i will close this as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

5 participants