Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14521,7 +14521,7 @@ const LANG_TO_EXTENSION = {
};
const BASE_URL = "https://leetcode.com";

const delay = (ms) => new Promise((res) => setTimeout(res, ms));
const delay = ms => new Promise(res => setTimeout(res, ms));

function log(message) {
console.log(`[${new Date().toUTCString()}] ${message}`);
Expand Down Expand Up @@ -14756,6 +14756,13 @@ function addToSubmissions(params) {
submissions,
} = params;

if (!response?.data?.data?.submissionList?.submissions) {
throw new Error(
"No LeetCode submissions found. This may be caused by an expired session. " +
"Please check if your LEETCODE_SESSION environment variable is valid and up to date."
);
}

for (const submission of response.data.data.submissionList.submissions) {
submissionTimestamp = Number(submission.timestamp);
if (submissionTimestamp <= lastTimestamp) {
Expand Down Expand Up @@ -14864,6 +14871,7 @@ async function sync(inputs) {
graphql,
{ headers }
);

log(`Successfully fetched submission from LeetCode, offset ${offset}`);
return response;
} catch (exception) {
Expand Down
10 changes: 9 additions & 1 deletion src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const LANG_TO_EXTENSION = {
};
const BASE_URL = "https://leetcode.com";

const delay = (ms) => new Promise((res) => setTimeout(res, ms));
const delay = ms => new Promise(res => setTimeout(res, ms));

function log(message) {
console.log(`[${new Date().toUTCString()}] ${message}`);
Expand Down Expand Up @@ -267,6 +267,13 @@ function addToSubmissions(params) {
submissions,
} = params;

if (!response?.data?.data?.submissionList?.submissions) {
throw new Error(
"No LeetCode submissions found. This may be caused by an expired session. " +
"Please check if your LEETCODE_SESSION environment variable is valid and up to date."
);
}

for (const submission of response.data.data.submissionList.submissions) {
submissionTimestamp = Number(submission.timestamp);
if (submissionTimestamp <= lastTimestamp) {
Expand Down Expand Up @@ -375,6 +382,7 @@ async function sync(inputs) {
graphql,
{ headers }
);

log(`Successfully fetched submission from LeetCode, offset ${offset}`);
return response;
} catch (exception) {
Expand Down