Skip to content

Commit

Permalink
fix: remove workaround with got@12
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Nov 13, 2021
1 parent 4b2213b commit ab9342f
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions source/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ function nextFetchTimeStr(minutes: number) {
.replace('T', ' ');
}

function gotBugWorkaround(req) {
req.prependOnceListener('cacheableResponse', (cacheableResponse) => {
const fix = () => {
if (!cacheableResponse.req) {
return;
}
cacheableResponse.complete = cacheableResponse.req.res.complete;
};
cacheableResponse.prependOnceListener('end', fix);
fix();
});
}

async function handleErr(e: Messager, feed: Feed): Promise<void> {
logger.info(`${feed.feed_title} ${feed.url}`, 'ERROR_MANY_TIME');
const message: ErrorMaxTimeMessage = {
Expand Down Expand Up @@ -86,9 +73,7 @@ async function fetch(feedModal: Feed): Promise<Option<any[]>> {
'If-Modified-Since': feedModal.last_modified_header
}
});
if (config.http_cache) {
request.on('request', gotBugWorkaround);
}

const res = await request;
if (res.statusCode === 304) {
const updatedFeedModal: Partial<Feed> & { feed_id: number } = {
Expand Down

0 comments on commit ab9342f

Please sign in to comment.