Skip to content

fix: treat Puppeteer session cookies as valid in Instagram_cookiesExist#100

Merged
David-patrick-chuks merged 5 commits into
David-patrick-chuks:mainfrom
GEEKYFOCUS:fix/instagram-session-cookie-expiry
Jun 21, 2026
Merged

fix: treat Puppeteer session cookies as valid in Instagram_cookiesExist#100
David-patrick-chuks merged 5 commits into
David-patrick-chuks:mainfrom
GEEKYFOCUS:fix/instagram-session-cookie-expiry

Conversation

@GEEKYFOCUS

Copy link
Copy Markdown
Contributor

Summary

  • Fix Instagram_cookiesExist() so Puppeteer session cookies (expires: -1) are recognized as valid instead of treated as expired
  • Add isCookieValid() helper and unit tests covering session, expired, and future timed cookies

Problem

Puppeteer marks session cookies with expires: -1. The previous check only accepted cookies where expires > currentTimestamp, so valid saved sessions were skipped and the IG client fell back to credential login on every run.

Test plan

  • npm test — all 27 tests pass (4 new cookie validation tests)
  • Verified session cookie (expires: -1) returns true from Instagram_cookiesExist()
  • Verified expired and future timed cookies behave correctly

Made with Cursor

Session cookies saved by Puppeteer use expires -1, which was incorrectly
treated as expired and forced unnecessary credential logins.
@GEEKYFOCUS GEEKYFOCUS force-pushed the fix/instagram-session-cookie-expiry branch from a296d9c to 2976259 Compare June 21, 2026 13:03
@David-patrick-chuks

Copy link
Copy Markdown
Owner

Thanks for this contribution!

This PR currently has merge conflicts with main (likely due to recent changes including the PostgreSQL migration). Please rebase your branch onto the latest main and resolve the conflicts:

git fetch origin
git checkout fix/instagram-session-cookie-expiry
git rebase origin/main
# resolve conflicts, then:
git add .
git rebase --continue
git push --force-with-lease

Once conflicts are resolved and CI is green, this will be ready for review/merge.

- Fix missing closing brace in withFileLock function that caused parsing error
- Remove duplicate isCookieValid definitions
- Add eslint.config.js for ESLint v9+ compatibility
- Ensure isCookieValid properly handles session cookies with expires=-1
@GEEKYFOCUS

Copy link
Copy Markdown
Contributor Author

Hi Maintainer. Kindly review the PR .

…bility

- Updated lint script: 'eslint src --ext .ts' -> 'eslint src'
- Updated lint:fix script: 'eslint src --ext .ts --fix' -> 'eslint src --fix'
- ESLint v9+ no longer supports the --ext flag
- File patterns are now defined in eslint.config.js
- Format eslint.config.js
- Format src/utils/index.test.ts
@GEEKYFOCUS

Copy link
Copy Markdown
Contributor Author

Hi Maintainer, Please review the changes

@David-patrick-chuks David-patrick-chuks merged commit 5723201 into David-patrick-chuks:main Jun 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants