May 21 07:35
@Bergi I don't have any specific evidence, just saying that there's a ton of stuff that needs done in JS land before something can go actually do that HTTP request, and more importantly... it's not surprising if you block in a tight loop, you've probably blocked something else, and that it's not magic. I know you know this, and that a specific answer is desirable... that's why I'm just commenting and not posting an answer.
May 21 07:35
@PranavK If you'd let the JS engine come up for air in your loop, you could still do your loop while the Fetch call runs. Tight loops are fine if you actually need them, but as you see they'll block some things. The Fetch API call isn't magic... there are probably references to things back here on this main thread that need to clear up, and since you've starved it from any CPU, then that isn't going to happen. Someone with more knowledge can explain the specifics, but basically... the engine is fine, the documentation is fine, and you're taking examples too literally.
 

The Meta Room

General chat & hangout for Stack Overflow, including Meta disc...
Jun 23, 2020 22:38
@Nick I can't even find it... I'm probably not the only one. Why would anyone want to move the discussion here, where it can't be discussed asynchronously and in-context?
Jun 23, 2020 20:45
@SamuelLiew It's crazy to me that you locked this question: https://meta.stackoverflow.com/questions/398537/what-can-we-do-to-encourage-downvoting?cb=1

"I'll be pruning some comments here since the discussion got lengthy." Isn't that the entire point of meta? What's the point of meta if we're not able to have a discussion? I'd comment about it there, but you've locked the post.
 
May 7, 2020 22:39
I'm not asking you to post your file, I'm asking you to show us what you're trying to do, in your question.
May 7, 2020 22:39
I was going to help you refactor this, but if you'd rather I don't, fine. You have a lot of misconceptions here, and I thought I'd help you get pointed in the right direction. Please edit your question with the example... the comments box is eating the formatting. Also, if that isn't a fake name/address... please make it one.
May 7, 2020 22:39
To answer your question exactly... you can use .off(). But this of course does nothing to solve your actual problem.
May 7, 2020 22:39
Can you show us an actual example of the data, and the actual example of the line you want to write?
May 7, 2020 22:39
Why not use one of the many off-the-shelf CSV encoders? They have built-in escape sequences so you don't have to worry about the separators in the strings. Or, something standard like JSON or CBOR?
May 7, 2020 22:39
This looks like a doozie. :-) Can you show what the format is that you're trying to write to a file? We can probably help you refactor it. Also, consider implementing a TransformStream instead of this. That way, you can pipe the output wherever. What you're doing with the drain and what not doesn't make sense.
May 7, 2020 22:39
Show your code where you're adding this listener in the first place.
 
Feb 5, 2020 14:40
A few things you can do with no JavaScript that used to require a lot of JavaScript: Audio/video streaming. Animation. Hover styling. (In fact, that may be an option for that menu... not the best from a usability perspective, but possible to override in JS later!) Deferred loading of fonts. Audio/video/photo capture. Force-a-download. Vector graphics, with animation. Probably 100 other things...
Feb 5, 2020 14:40
@messerbill Your definition of "modern" is interesting...
Feb 5, 2020 14:40
@messerbill Of course it's possible to build modern websites without JavaScript... Depends entirely on what you need to do.
Feb 5, 2020 14:40
This question shouldn't have been closed. It's definitely not strictly opinion based... there's a real factual question here.
Feb 5, 2020 14:40
> is using Javascript bad practice in web design? No. > The thing is that the hamburger menu won't open when people have their Javascript disabled What if that menu were open by default, and you only closed it with JavaScript? Best practice on the web is all about progressive enhancement. If there's anything you can do to support folks who are using alternative user agents, then you should. It's not just people who have JavaScript disabled... it's crawlers, console browsers, alternative inputs, old screen readers, etc.
 
Oct 4, 2019 00:48
@BluLotus Without actually seeing your data, it's hard to say. JSONStream is solid, but any parser handling an incomplete document has its tradeoffs, as you have seen. Can you show the code you're using to set up the parser?
Oct 4, 2019 00:48
@BluLotus Do you need to use a streaming parser in this way? Most of the time, line-delimited JSON (NDJSON) is a more appropriate choice. (If you have a lot of records, use NDJSON. If you have big complex structure, you may not be able to.)
Oct 4, 2019 00:48
There are lots of streaming JSON readers... can you clarify which one you're using? Also, what does your actual file look like and what are you trying to retrieve? While JSON does technically support keys with the same name, I've never seen it used in practice.
 
Dec 7, 2018 15:53
In any case, having that question open longer harms no one. I see zero benefit to having a question closed in 2 minutes, vs an hour, or even days. I think long-term cleanup is great as people tend to find things on Stack Overflow via Google. But, I see no reason on borderline questions like this to have moderator action. To me, this question was clear-cut answerable, since four people answered it (3 in comments, 1 in answer).
Dec 7, 2018 15:47
I have no idea if that's reality or not, but that's my perception.
Dec 7, 2018 15:47
I've seen this happen several times.
Dec 7, 2018 15:47
Once I do that, the downvotes either slow down or stop.
Dec 7, 2018 15:47
The reason I think this happens is that I've gone to questions like this where there was often some literal interpretation of some poorly translated title, where people will pile on and downvote, until I come in, take the 20 seconds it takes to actually figure out what the real question is, and then comment on it as such.
Dec 7, 2018 15:46
I would love to try an experiment sometime... post two copies of a question that is borderline clear/unclear. Start one with a couple downvotes. Another with a couple upvotes. Perhaps yet another with moderator vote-to-close action. I think (but obviously haven't proven) that there's this dogpile effect where people see a question already downvoted and go to it specifically for that reason to go say, "yeah fuck that guy!", and downvote and pile on the comments unnecessarily.
Dec 7, 2018 15:42
@FunkFortyNiner I'm not saying he's breaking any rules, or even guidelines... just saying that such swift moderator action wasn't helpful. As for where Op is, the question was posted only a half hour ago... I wouldn't necessarily expect everyone to be able to constantly watch a question they posted. In any case, if others came by to vote to close, even if rapidly, that'd be fine in my opinion.
Dec 7, 2018 15:42
@deceze Yes. People tend to dogpile. In any case, if you think that leaving the question open for a minute or two would have led to the same outcome, what's the problem with waiting to see? Worst case scenario, the question stays open for 2 minutes longer. Best case scenario, the question is updated, answered (that part happened), and the problem is solved.
Dec 7, 2018 15:42
Let me put this another way... if four of you had independently voted to close the question, that's fine. That's how this is supposed to work. That's not what happened... instead we have (in my opinion) moderator overreach on a borderline question. If it's borderline, leave it to the community to decide what to do. Moderation should be here for solving the problems that non-moderators cannot.
Dec 7, 2018 15:42
@apokryfos Isn't this how almost all questions go? A misunderstanding, a false assertion, and then an answer that clarifies the original understanding. 80% of an answer to this question is the fact that what this person is looking at isn't the PHP source code.
Dec 7, 2018 15:42
@deceze Yeah, we're guessing so much here that 4 people independently posted the same answer... No doubt some clarification would be nice, but I don't think this question was bad enough to be insta-closed by a mod.
Dec 7, 2018 15:42
This is a perfectly fine question... no idea why this was downvoted and closed. You could have posted an answer instead. @deceze A light touch on the moderation for questions like these would be appreciated. It would be one thing if it had the four close-votes, but it didn't.
 
Dec 14, 2015 01:23
Thanks, and thanks again for all of your help.
Dec 14, 2015 01:17
I think for now I'll just make a Node.js supervisor for VLC.
Dec 14, 2015 01:16
So, I'm trying to hack around the problem.
Dec 14, 2015 01:16
For context, I'm working on the stream source for RadioReddit.com. We have 8 genre-based streams. I have my own internet radio company, AudioPump, Inc., and Radio Reddit and many of my other customers are fed up with Liquidsoap. So, we're trying an experiment to see how viable VLC is for a stream source. The streams work fine, but the big catch is that metadata doesn't work. The shout sout plugin doesn't support updating metadata unless you're using the Ogg muxer.
Dec 14, 2015 01:14
Ha, well I could even return something valid. I control the API I need to hit.
Dec 14, 2015 01:13
or something like that
Dec 14, 2015 01:13
function fetch_meta()
return "http://example.com/myscript?item=" + vlc.item:uri()
end
Dec 14, 2015 01:12
Any way I could return a URL to force VLC to hit it, even with a GET request? Album art or something?
Dec 14, 2015 01:12
I wonder why they bother with the "network" descriptor value then.
Dec 14, 2015 01:11
Unless you know how I can make an HTTP request from a metadata script?
Dec 14, 2015 01:10
Fortunately the messages I need are already there. I just need to write some regex for parsing. At this point, I think that's what I'm going to have to do, ha.
Dec 14, 2015 01:09
[0x7fa940000958] main input debug: http://api.radioreddit.com/tracks/7495/media/original?.mp3' successfully opened`
Dec 14, 2015 01:09
At this point, I'm near executing VLC via Node.js and parsing the STDERR stream to figure out what VLC is playing. :-)
Dec 14, 2015 01:08
They seem to imply it's possible however. It can be either a "local" or "network" script... so if network, I'm not sure how that'd work without net.
Dec 14, 2015 01:08
Right... that's the problem... not sure how to do HTTP requests from there.
Dec 14, 2015 01:07
It seems to work fine...

```
function descriptor()
return { scope="local" }
end

function fetch_meta()
local metas = vlc.item:metas()

vlc.msg.info(metas["filename"])
end
```
Dec 14, 2015 01:06
I can't use an extension because there is seemingly no way to load it on the command line. I was hoping to make an interface which I can easily load on the command line, but there is seemingly no way to get events for when the track changes using the interface API. (Please correct me if I'm wrong on that.) So what I've done is put a script in lua/meta/fetcher that implements fetch_ meta(). When a new track is played, this is called and I can infer in my script that a track is playing. (Hopefully VLC never tries to use it to get metadata at other times.)
Dec 14, 2015 01:06
Thank you very much for this information. I'll award the bounty as soon as Stack Overflow lets me. For my use case, I need to run cvlc and have VLC hit an HTTP server with track updates. I think that since I cannot load an extension directly, I'll have to use the metadata fetching Lua script method. I have this working... it's hacky but sort of works. Thanks again for all of your help! It's too bad the scrobbler URL config parameter on the last.fm plugin doesn't work correctly... I could just use that directly.