File tree Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " react-email " : patch
3
+ ---
4
+
5
+ fix linting hanging because of missing images
Original file line number Diff line number Diff line change 1
- import { promises as fs } from 'node:fs' ;
1
+ import { promises as fs , existsSync } from 'node:fs' ;
2
2
/* eslint-disable @typescript-eslint/no-non-null-assertion */
3
3
import type http from 'node:http' ;
4
4
import path from 'node:path' ;
@@ -16,25 +16,29 @@ export const serveStaticFile = async (
16
16
17
17
const fileAbsolutePath = path . join ( staticBaseDir , pathname ) ;
18
18
19
- const fileHandle = await fs . open ( fileAbsolutePath , 'r' ) ;
20
-
21
19
try {
20
+ const fileHandle = await fs . open ( fileAbsolutePath , 'r' ) ;
22
21
const fileData = await fs . readFile ( fileHandle ) ;
23
22
24
23
// if the file is found, set Content-type and send data
25
24
res . setHeader ( 'Content-type' , lookup ( ext ) || 'text/plain' ) ;
26
25
res . end ( fileData ) ;
27
- } catch ( exception ) {
28
- console . error (
29
- `Could not read file at ${ fileAbsolutePath } to be served, here's the exception:` ,
30
- exception ,
31
- ) ;
32
26
33
- res . statusCode = 500 ;
34
- res . end (
35
- 'Could not read file to be served! Check your terminal for more information.' ,
36
- ) ;
37
- } finally {
38
27
fileHandle . close ( ) ;
28
+ } catch ( exception ) {
29
+ if ( ! existsSync ( fileAbsolutePath ) ) {
30
+ res . statusCode = 404 ;
31
+ res . end ( ) ;
32
+ } else {
33
+ console . error (
34
+ `Could not read file at ${ fileAbsolutePath } to be served, here's the exception:` ,
35
+ exception ,
36
+ ) ;
37
+
38
+ res . statusCode = 500 ;
39
+ res . end (
40
+ 'Could not read file to be served! Check your terminal for more information.' ,
41
+ ) ;
42
+ }
39
43
}
40
44
} ;
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ export const useCachedState = <T>(key: string) => {
4
4
let value : T | undefined = undefined ;
5
5
if ( 'localStorage' in global ) {
6
6
const storedValue = global . localStorage . getItem ( key ) ;
7
- if ( storedValue !== null ) {
7
+ if ( storedValue !== null && storedValue !== 'undefined' ) {
8
8
try {
9
9
value = JSON . parse ( storedValue ) as T ;
10
10
} catch ( exception ) {
11
11
console . warn (
12
12
'Failed to load stored value for' ,
13
13
key ,
14
14
'with value' ,
15
- value ,
15
+ storedValue ,
16
16
) ;
17
17
}
18
18
}
You can’t perform that action at this time.
0 commit comments