Skip to content

Commit

Permalink
Merge pull request #1346 from remotion-dev/dont-throw-error-if-gif-is…
Browse files Browse the repository at this point in the history
…-aborted
  • Loading branch information
JonnyBurger committed Sep 27, 2022
2 parents ad29e24 + d766bee commit 3039ce3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/gif/src/GifForDevelopment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const GifForDevelopment = forwardRef<

useEffect(() => {
let done = false;
let aborted = false;
const {prom, cancel} = parseWithWorker(resolvedSrc);
const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc);

Expand All @@ -52,6 +53,10 @@ export const GifForDevelopment = forwardRef<
continueRender(id);
})
.catch((err) => {
if (aborted) {
return;
}

if (currentOnError.current) {
currentOnError.current(err);
} else {
Expand All @@ -61,6 +66,7 @@ export const GifForDevelopment = forwardRef<

return () => {
if (!done) {
aborted = true;
cancel();
}

Expand Down
6 changes: 6 additions & 0 deletions packages/gif/src/GifForRendering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
useEffect(() => {
const controller = new AbortController();
let done = false;
let aborted = false;
const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc);

parseGif({controller, src: resolvedSrc})
Expand All @@ -51,6 +52,10 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
continueRender(id);
})
.catch((err) => {
if (aborted) {
return;
}

if (currentOnError.current) {
currentOnError.current(err);
} else {
Expand All @@ -60,6 +65,7 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(

return () => {
if (!done) {
aborted = true;
controller.abort();
}

Expand Down

1 comment on commit 3039ce3

@vercel
Copy link

@vercel vercel bot commented on 3039ce3 Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.