Closed JakobTischler closed 2 days ago
Mmh since I released 0.1.8
today there may be a problem in a library I have to investigate. On my Linux it works as expected... Maybe I should un-release the 0.1.8
for now until this is clear. Thanks for reporting this so quick.
Probably this has to do something with the AnsiConsole
-Width problem (#68)
@JakobTischler
So it seems to me that you are using tone
via JavaScript / NodeJS and posted the according error message, that probably does not have to do anything with tone
's error system?
I'm a bit confused, because tone
also has a JavaScript engine and I'm not sure where this error might come from...
Here is my guess:
tone
via NodeJS shell execution wrappertone
detects, that output is going to be redirected and prevents line wrapping to not break JSON content (which was changed in 0.1.8
)maxBuffer length exceeded
Would that be possible?
You're possibly correct. I'm indeed using this in a NodeJS environment.
I async call child_process
→exec
inside a promise:
import { exec } from 'child_process';
export default function commandPromise(command: string) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
return reject(error);
// throw error;
}
if (stdout) {
console.log(stdout);
resolve(stdout);
}
if (stderr) {
return reject(stderr);
// throw stderr;
}
});
});
}
If I understand you correctly, it would be child_process.exec
's buffer problem. I've found this StackOverflow answer to a similar problem. The solution would be to simply increase the maxBuffer with the exec call.
I'll try it out later tonight and will let you know.
I'll try it out later tonight and will let you know.
Ok, since I unreleased tone 0.1.8
because of this problem, you might have to use your existing version.
However, while the fix could have worked, it seems that there are edge cases like yours, that have to be handled more carefully and require more thinking.
I probably go for the solution to use Console.WriteLine
on non spectre-console output. Thanks for the quick feedback.
So that didn't work. I tried different buffer sizes, from 500 kB to 200 MB. All ended in stdout maxBuffer length exceeded
.
So that didn't work. I tried different buffer sizes, from 500 kB to 200 MB. All ended in stdout maxBuffer length exceeded.
Thanks for the feedback. I'll try to fix this the right way and then release 0.1.8
again.
@JakobTischler Could you give me the complete command you are executing?
Here is the problem: I found no decent way to fix #68 (which is a really nasty bug that MUST be fixed) without the lines that break your code.
What I could do is provide either an environment variable TONE_OUTPUT_REDIRECT=0
(or an extra parameter (like --no-output-redirect
) that you could set to fix your use case. I really don't want to do this, but every suggested solution (e.g. use Console.WriteLine
instead of AnsiConsole.WriteLine
) did not work in my tests.
If anyone can provide a solution that works without this pretty annoying workaround, I'd be happy to listen...
I have one command in the error log in the opening post, but here it is for reference:
tone tag "Y:/Audio/Podcasts_TEMP/Comedy Bang Bang/2024/Comedy Bang Bang - 879 - Side Duck (2024-08-26) [Haley Joel Osment, Jon Gabrus, Vic Michaelis].mp3"
--auto-import=covers
--meta-artist "Scott Aukerman, Haley Joel Osment, Jon Gabrus, Vic Michaelis"
--meta-sort-artist "Aukerman, Scott"
--meta-album-artist "Scott Aukerman"
--meta-sort-album-artist "Aukerman, Scott"
--meta-album "Comedy Bang Bang"
--meta-composer "Haley Joel Osment, Jon Gabrus, Vic Michaelis"
--meta-cover-file "Y:\\Audio\\Podcasts\\Comedy Bang Bang\\cover.jpeg"
--meta-genre "Podcast//Comedy"
--meta-disc-number "1"
--meta-title "Side Duck"
--meta-additional-field "year=2024-08-26"
--meta-additional-field "date=2024-08-26"
--meta-additional-field "releaseDate=2024-08-26"
--meta-publishing-date "2024-08-26"
--meta-additional-field "language=eng"
--meta-additional-field "podcast=1"
--meta-track-number "879"
--meta-movement "879"
--meta-comment "Academy Award nominated actor Haley Joel Osment joins Scott to talk about his new movie Blink Twice, where he would live for 180 days out of the year, and the 25th anniversary of The Sixth Sense. Then, intern Gino Lombardo returns to talk about his recent run-in with the law
in Nassau County for wearing a mask. Plus, Pokémon trainer Ember Chuckit stops by to talk about a pilot program that Professor Oak is running. Get tickets for the Comedy Bang! Bang! Into Your Mouth Tour 2024 over at <a href='https://cbbworld.com/tour' rel='noopener noreferrer' target='_blank'><u>https://CBBWorld.com/tour</u></a>Check out The Action Boyz Live on Saturday, September 7th at The Dynasty Typewriter in Los Angeles. For tickets go to <a href='https://live.actionboyz.biz/' rel='noopener noreferrer' target='_blank'><u>live.actionboyz.biz</u></a>"
--meta-additional-field "unsyncedLyrics=eng||Academy Award nominated actor Haley Joel Osment joins Scott to talk about his new movie Blink Twice, where he would live for 180 days out of the year, and the 25th anniversary of The Sixth Sense. Then, intern Gino Lombardo returns to talk about his recent run-in with the law in Nassau County for wearing a mask. Plus, Pokémon trainer Ember Chuckit stops by to talk about a pilot program that Professor Oak is running. Get tickets for the Comedy Bang! Bang! Into Your Mouth Tour 2024 over at <u>https://CBBWorld.com/tour</u>Check out The Action Boyz Live on Saturday, September 7th at The Dynasty Typewriter in Los Angeles. For tickets go to <u>live.actionboyz.biz</u>"
--meta-sort-album "Comedy Bang Bang"
--meta-movement-name "Comedy Bang Bang"
I've done some tests just now concerning command length being used, and had some interesting results. As you can see in the command, the comment
tag is rather long. Additionally, the same content is added to the unsyncedlyrics
tag, with unsyncedLyrics=eng||...
.
If I remove the comment tag, it still fails. If I remove the unsyncedLyrics tag, though, it goes through. I'm not sure if I'm right on the cusp of the max buffer length, or if there's another problem with unsyncedLyrics.
EDIT: Sometimes. It sometimes goes through, so still seems to be a size problem.
If I remove the comment tag, it still fails. If I remove the unsyncedLyrics tag, though, it goes through. I'm not sure if I'm right on the cusp of the max buffer length, or if there's another problem with unsyncedLyrics.
You could try to generating a temporary tone.json
file instead (tone tag --meta-tone-json-file /tmp/use-these-tags.json my-file.mp3
). This would prevent having to long commands exceeding the buffer.
I'd suggest the following solution:
TONE_OUTPUT_REDIRECT=0
to force the behaviour of version 0.1.7
(I don't want to provide an extra parameter, because I would like to keep these as clean as possible)In case it really is the new Console.WriteLine
handling that causes your problems, you could just set the environment variable in your code as a workaround (untested, just a draft):
import { exec } from 'child_process';
export default function commandPromise(command: string) {
return new Promise((resolve, reject) => {
exec(command, {env: Object.assign({}, process.env, {"TONE_OUTPUT_REDIRECT": "0"})}, (error, stdout, stderr) => {
if (error) {
return reject(error);
// throw error;
}
if (stdout) {
console.log(stdout);
resolve(stdout);
}
if (stderr) {
return reject(stderr);
// throw stderr;
}
});
});
}
What do you think?
Fixed in 0.1.8
- see https://github.com/sandreas/tone?tab=readme-ov-file#dump-tags - section "redirecting output".
@sandreas Thanks for the workaround. Just got around to testing, and as you predicted it works like a charm.
Thanks for your help, and - as always - for your work in general.
Thanks for your help, and - as always - for your work in general.
You're very welcome :-)
Any
tone tag ...
command I've tried with v0.1.8 ends up in anstdout maxBuffer length exceeded
error. Using v0.1.7 does not produce this error with the same commands. I'm usingtone-0.1.8-win-x64.zip
on Windows 10.Example output:
Many thanks for your help.