Skip to content

Commit

Permalink
Merge pull request #4440 from remotion-dev/media-parser-memory-leak
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger authored Oct 30, 2024
2 parents 6694007 + df460ce commit 61841d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/media-parser/src/parse-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export const parseMedia: ParseMedia = async ({
);
}

currentReader.abort();

const {reader: newReader} = await readerInterface.read(
src,
parseResult.skipTo,
Expand Down
5 changes: 4 additions & 1 deletion packages/media-parser/src/readers/from-web-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ export const webFileReader: ReaderInterface = {

return new Promise((resolve, reject) => {
reader.onload = () => {
const stream = part.stream();
const streamReader = stream.getReader();
resolve({
reader: {
reader: part.stream().getReader(),
reader: streamReader,
abort() {
streamReader.cancel();
controller.abort();
},
},
Expand Down

0 comments on commit 61841d8

Please sign in to comment.