Altinn / Altinn/app-frontend-react

Consider failing #readyForPrint if image fails to load

Open
#3,252 0 comments 0 reactions 0 assignees View on GitHub
kind/analysis status/draft
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

### Description

We keep track of and wait for images to load before showing `#readyForPrint`, but we consider both the `load`-event and the `error`-event as equal. So if an image fails to load, we will still print the page instead of failing and allowing the user to retry.

![Image](https://github.com/user-attachments/assets/6ebf8224-1b63-46da-9d40-a894d0654250)

In general, generating a PDF on with incorrect content is much more destructive and difficult to fix later than simply failing it so it can be retried until successful. So we should consider removing the event-listener for `error`, and maybe also checking for failures explicitly in case the image fails before this logic has a chance to run.

Is there any way to retry loading failed images?

Related to https://github.com/Altinn/app-frontend-react/issues/3250, although this seems to take more than 30s to fail so the PDF times out anyway. But this is not guaranteed to happen like this in general.

### In scope

_No response_

### Out of scope

_No response_

### Additional Information

_No response_

### Analysis

_No response_

### Conclusion

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the #readyForPrint logic that tracks image load and error events. Check how failed images are handled before and during this wait, then define completion as preventing printing when an image fails and allowing a retry where supported; the issue does not name a file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.