Skip to content

Commit

Permalink
Add graceful error handling for sharp errors
Browse files Browse the repository at this point in the history
Handle errors from sharp

Revert "Handle errors from sharp"

This reverts commit 70f6268.

Handle any sharp errors gracefully

Add Toast Messages for Bad Logins (LemmyNet#1874)

* Added toast prompts

* Using generic  message instead.

---------

Co-authored-by: Jacob Rosenzweig <rosenjcb@Jacobs-MacBook-Pro.local>
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>

Fix CSP in dev mode (LemmyNet#1918)

Remove invalid default option from language list (LemmyNet#1919)

Set person_id to myId in handleLeaveModTeam (LemmyNet#1929)
  • Loading branch information
andrewstuart committed Jul 27, 2023
1 parent 88f89cb commit d245977
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
43 changes: 27 additions & 16 deletions src/server/utils/create-ssr-html.tsx
Expand Up @@ -30,22 +30,33 @@ export async function createSsrHtml(
);

if (!appleTouchIcon) {
appleTouchIcon = site?.site_view.site.icon
? `data:image/png;base64,${await sharp(
await fetchIconPng(site.site_view.site.icon)
)
.resize(180, 180)
.extend({
bottom: 20,
top: 20,
left: 20,
right: 20,
background: "#222222",
})
.png()
.toBuffer()
.then(buf => buf.toString("base64"))}`
: favIconPngUrl;
try {
appleTouchIcon = site?.site_view.site.icon
? `data:image/png;base64,${await sharp(
await fetchIconPng(site.site_view.site.icon)
)
.resize(180, 180)
.extend({
bottom: 20,
top: 20,
left: 20,
right: 20,
background: "#222222",
})
.png()
.toBuffer()
.then(buf => buf.toString("base64"))}`
: favIconPngUrl;
} catch (err) {
console.error(err);
console.error(
"error resizing apple touch icon",
180,
site?.site_view.site.name,
site?.site_view.site.name,
err
);
}
}

const erudaStr =
Expand Down
20 changes: 15 additions & 5 deletions src/server/utils/generate-manifest-json.ts
Expand Up @@ -38,11 +38,21 @@ export default async function ({
).then(buf => buf.toString("base64"));

if (icon) {
src = await sharp(icon)
.resize(size, size)
.png()
.toBuffer()
.then(buf => buf.toString("base64"));
try {
src = await sharp(icon)
.resize(size, size)
.png()
.toBuffer()
.then(buf => buf.toString("base64"));
} catch (err) {
console.error(
"error with resizing manifest icon: ",
size,
site.icon,
site.name,
err
);
}
}

return {
Expand Down

0 comments on commit d245977

Please sign in to comment.