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

Edge case in parser #8

Open
danielepolencic opened this issue May 9, 2024 · 0 comments
Open

Edge case in parser #8

danielepolencic opened this issue May 9, 2024 · 0 comments
Assignees

Comments

@danielepolencic
Copy link

danielepolencic commented May 9, 2024

Unintentionally, I fed an mp4 file to this library (yes, I know, not really the ideal usage. But bear with me for a moment).

The parser function failed with:

TypeError: Cannot read properties of undefined (reading 'replace')
    at timestampToMillisecond (/private/var/tmp/_bazel_danielepolencic/198d81e4f6aafdc263b492f2c04a5df7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/packages/main/main.sh.runfiles/_main/node_modules/.aspect_rules_js/@[email protected]/node_modules/@plussub/srt-vtt-parser/dist/src/srtParser.js:18:29)
    at Object.TIME_LINE (/private/var/tmp/_bazel_danielepolencic/198d81e4f6aafdc263b492f2c04a5df7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/packages/main/main.sh.runfiles/_main/node_modules/.aspect_rules_js/@[email protected]/node_modules/@plussub/srt-vtt-parser/dist/src/srtParser.js:60:24)
    at Object.start (/private/var/tmp/_bazel_danielepolencic/198d81e4f6aafdc263b492f2c04a5df7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/packages/main/main.sh.runfiles/_main/node_modules/.aspect_rules_js/@[email protected]/node_modules/@plussub/srt-vtt-parser/dist/src/srtParser.js:30:51)
    at Object.srtParser (/private/var/tmp/_bazel_danielepolencic/198d81e4f6aafdc263b492f2c04a5df7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/packages/main/main.sh.runfiles/_main/node_modules/.aspect_rules_js/@[email protected]/node_modules/@plussub/srt-vtt-parser/dist/src/srtParser.js:99:31)
    at parse (/private/var/tmp/_bazel_danielepolencic/198d81e4f6aafdc263b492f2c04a5df7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/packages/main/main.sh.runfiles/_main/node_modules/.aspect_rules_js/@[email protected]/node_modules/@plussub/srt-vtt-parser/dist/src/index.js:7:80

So I started digging and found that this line could be undefined.

While I recognised my error and fixed it, I wondered if there was something I could do to prevent this library from crashing again at that particular point (my current thinking is that a broken VTT file might cause the issue). I think the library should either:

  • Return an error if the file is invalid
  • throw an error
  • or return partial results.

How to reproduce the issue:

try {
  const caption = await axios.get('https://f005.backblazeb2.com/file/kubefm/interview-miguel-luna-1/social-1.mp4')

  console.log('VTT', parseVTT(caption.data as string))
} catch (error) {
  console.log('Err', error)
}
@ste-xx ste-xx self-assigned this Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants