torrent-online 1.4.9 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/wtui.js +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "torrent-online",
3
- "version": "1.4.9",
3
+ "version": "1.4.10",
4
4
  "type": "module",
5
5
  "description": "Stream .torrent / magnet to VLC or browser — torrent streaming for macOS/Linux without a torrent client. Стрим торрентов в VLC или браузер.",
6
6
  "keywords": [
package/wtui.js CHANGED
@@ -194,6 +194,15 @@ function contentTypeByExt(ext) {
194
194
 
195
195
  function makeServer(torrent, base) {
196
196
  return http.createServer((req, res) => {
197
+ try {
198
+ handleReq(req, res, torrent, base);
199
+ } catch (e) {
200
+ if (!res.headersSent) { res.statusCode = 500; res.end('stream error'); }
201
+ console.error('server:', e?.stack || e);
202
+ }
203
+ });
204
+ }
205
+ function handleReq(req, res, torrent, base) {
197
206
  const u = new URL(req.url, 'http://127.0.0.1');
198
207
  let p = u.pathname;
199
208
  if (base) {
@@ -253,7 +262,6 @@ function makeServer(torrent, base) {
253
262
  res.setHeader('Content-Length', total);
254
263
  file.createReadStream().pipe(res);
255
264
  }
256
- });
257
265
  }
258
266
 
259
267
  // ---- Поиск индексаторов ----
@@ -622,6 +630,7 @@ async function main() {
622
630
  const msg = (e && (e.message || e)) + '';
623
631
  if (NET_NOISE.test(msg)) return;
624
632
  console.error('uncaughtException:', msg);
633
+ console.error((e && e.stack || '').split('\n').slice(0, 8).join('\n'));
625
634
  shutdown('uncaught', 1);
626
635
  });
627
636
  if (vlc) vlc.on('exit', () => shutdown('VLC exit'));