Skip to content

Commit 4790109

Browse files
committed
hotfix: 배포 폭파 관련 문제 해결
1 parent 1e8671b commit 4790109

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

src/apis/instance.request.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const instance = async <I, R>(
4949
input: URL | RequestInfo,
5050
init?: InitType<I>,
5151
error?: Record<string, Error>,
52-
): Promise<R | void> => {
52+
): Promise<R> => {
5353
let cookieHeader = '';
5454
if (typeof window === 'undefined') {
5555
cookieHeader = (await import('next/headers')).cookies().toString();
@@ -77,26 +77,26 @@ export const instance = async <I, R>(
7777
const context = err as Response;
7878
if (location && !context.ok && context.status === 401) {
7979
window.location.replace('/');
80+
return {} as never;
81+
}
82+
setContext('Request', {
83+
path: context.url,
84+
status: context.status,
85+
});
86+
if ((err as Error).name === 'TimeoutError') {
87+
captureException(new ServerNotRespondingError());
88+
throw new ServerNotRespondingError();
8089
} else {
81-
setContext('Request', {
82-
path: context.url,
83-
status: context.status,
84-
});
85-
if ((err as Error).name === 'TimeoutError') {
86-
captureException(new ServerNotRespondingError());
87-
throw new ServerNotRespondingError();
88-
} else {
89-
if (!error?.[`${(err as Response).status}`]) {
90-
const serverError = new Error(
91-
`서버에서 예기치 않은 오류가 발생했습니다. (${(err as Error).name})`,
92-
);
93-
captureException(serverError);
94-
throw serverError;
95-
}
96-
97-
captureException(error[`${(err as Response).status}`]);
98-
throw error[`${(err as Response).status}`];
90+
if (!error?.[`${(err as Response).status}`]) {
91+
const serverError = new Error(
92+
`서버에서 예기치 않은 오류가 발생했습니다. (${(err as Error).name})`,
93+
);
94+
captureException(serverError);
95+
throw serverError;
9996
}
97+
98+
captureException(error[`${(err as Response).status}`]);
99+
throw error[`${(err as Response).status}`];
100100
}
101101
}
102102
};

src/app/(auth-required)/main/Content.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import { PATHS, SORT_TYPE } from '@/constants';
1010
import { SortKey, SortValue } from '@/types';
1111
import { Section, Summary } from './components';
1212

13-
const sorts: Array<[SortKey, SortValue]> = Object.entries(SORT_TYPE) as Array<
14-
[SortKey, SortValue]
15-
>;
13+
const sorts: Array<[SortKey, SortValue]> = Object.entries(SORT_TYPE) as Array<[SortKey, SortValue]>;
1614

1715
export const Content = () => {
1816
const [searchParams, setSearchParams] = useSearchParam<{
@@ -40,11 +38,7 @@ export const Content = () => {
4038
});
4139

4240
useEffect(() => {
43-
if (
44-
posts &&
45-
posts.pages[posts.pages?.length - 1].nextCursor !== null &&
46-
inView
47-
) {
41+
if (posts && posts.pages[posts.pages?.length - 1].nextCursor !== null && inView) {
4842
fetchNextPage();
4943
}
5044
}, [inView]);
@@ -64,8 +58,7 @@ export const Content = () => {
6458
새로고침
6559
</Button>
6660
<span className="text-TEXT-ALT text-ST4 max-TBL:text-ST5 max-MBI:hidden">
67-
마지막 업데이트 :{' '}
68-
{summaries?.stats?.lastUpdatedDate || '업데이트 중..'}
61+
마지막 업데이트 : {summaries?.stats?.lastUpdatedDate || '업데이트 중..'}
6962
</span>
7063
</div>
7164
<div className="flex items-center gap-3">
@@ -80,13 +73,10 @@ export const Content = () => {
8073
/>
8174
<Dropdown
8275
defaultValue={
83-
sorts.find((i) => i[1] === searchParams.sort) ??
84-
SORT_TYPE['작성일순']
76+
sorts.find((i) => i[1] === searchParams.sort) ?? SORT_TYPE['작성일순']
8577
}
8678
options={sorts}
87-
onChange={(data) =>
88-
setSearchParams({ sort: data as SortValue })
89-
}
79+
onChange={(data) => setSearchParams({ sort: data as SortValue })}
9080
/>
9181
</div>
9282
</div>

0 commit comments

Comments
 (0)