-
Notifications
You must be signed in to change notification settings - Fork 3
fix: remove proxy #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove proxy #192
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,11 @@ jobs: | |
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| - name: Tailscale | ||
| uses: tailscale/github-action@v3 | ||
| with: | ||
| authkey: ${{ secrets.TS_AUTHKEY }} | ||
| - run: npm ci | ||
| - uses: wenoa/[email protected] | ||
| with: | ||
| WG_CONFIG: ${{ secrets.WG_CONFIG }} | ||
| - run: npm run build | ||
| env: | ||
| PROXY_URL: ${{ secrets.SOLVERR_PROXY_URL }} | ||
| - run: npm test | ||
| - run: git checkout -- package-lock.json #prevent package-lock.json-only feat changes | ||
| - uses: stefanzweifel/git-auto-commit-action@v6 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,18 +40,15 @@ jobs: | |
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| - name: Tailscale | ||
| uses: tailscale/github-action@v3 | ||
| with: | ||
| authkey: ${{ secrets.TS_AUTHKEY }} | ||
| - uses: actions/cache/restore@v4 | ||
| id: restore-cache | ||
| with: | ||
| path: node_modules/ | ||
| key: ${{ runner.os }}-${{ github.run_id }}${{ github.run_number }} | ||
| - uses: wenoa/[email protected] | ||
| with: | ||
| WG_CONFIG: ${{ secrets.WG_CONFIG }} | ||
| - run: npm run build | ||
| env: | ||
| PROXY_URL: ${{ secrets.SOLVERR_PROXY_URL }} | ||
| - uses: actions/cache/save@v4 | ||
| with: | ||
| path: | | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,15 +7,6 @@ import sleep from './sleep.js'; | |||||||||||||||||
| import title from './title.js'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const baseUrl = 'https://forums.warframe.com/forum/3-pc-update-notes/'; | ||||||||||||||||||
| const proxyUrl = process.env.PROXY_URL; | ||||||||||||||||||
| const isCI = process.env.CI === 'true'; | ||||||||||||||||||
| const ciTimeout = process.env.CI_TIMEOUT ? parseInt(process.env.CI_TIMEOUT, 10) : 60000; | ||||||||||||||||||
| const localTimeout = process.env.LOCAL_TIMEOUT ? parseInt(process.env.LOCAL_TIMEOUT, 10) : 12000000; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!proxyUrl) { | ||||||||||||||||||
| console.error('PROXY_URL environment variable is not set.'); | ||||||||||||||||||
| process.exit(1); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Scraper to get patch logs from forums. | ||||||||||||||||||
|
|
@@ -47,38 +38,13 @@ class Scraper { | |||||||||||||||||
| process.exit(1); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| async #fetch(url = baseUrl, session = 'fetch-warframe') { | ||||||||||||||||||
| try { | ||||||||||||||||||
| const res = await fetch(`${proxyUrl}/v1`, { | ||||||||||||||||||
| method: 'POST', | ||||||||||||||||||
| headers: { 'Content-Type': 'application/json' }, | ||||||||||||||||||
| body: JSON.stringify({ | ||||||||||||||||||
| cmd: 'request.get', | ||||||||||||||||||
| url, | ||||||||||||||||||
| session, | ||||||||||||||||||
| maxTimeout: isCI ? ciTimeout : localTimeout, | ||||||||||||||||||
| returnOnlyCookies: false, | ||||||||||||||||||
| returnPageContent: true, | ||||||||||||||||||
| }), | ||||||||||||||||||
| }); | ||||||||||||||||||
| const { solution } = await res.json(); | ||||||||||||||||||
| if (!solution?.response) { | ||||||||||||||||||
| throw solution; | ||||||||||||||||||
| } | ||||||||||||||||||
| return solution.response; | ||||||||||||||||||
| } catch (error) { | ||||||||||||||||||
| console.error(`Failed to fetch from proxy ${url}:`, error); | ||||||||||||||||||
| throw error; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Retrieve number of post pages to look through. This value should be set to | ||||||||||||||||||
| * 1 through the constructor if we only need the most recent changes. | ||||||||||||||||||
| * @returns {Promise<number>} set the total number of pages | ||||||||||||||||||
| */ | ||||||||||||||||||
| async getPageNumbers() { | ||||||||||||||||||
| const html = await this.#fetch(undefined, 'get-page-numbers'); | ||||||||||||||||||
| const html = await fetch(baseUrl).then((r) => r.text()); | ||||||||||||||||||
| const $ = load(html); | ||||||||||||||||||
| const text = $('a[id^="elPagination"]').text().trim().split(' '); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -96,7 +62,7 @@ class Scraper { | |||||||||||||||||
| * @returns {void} | ||||||||||||||||||
| */ | ||||||||||||||||||
| async scrape(url) { | ||||||||||||||||||
| const html = await this.#fetch(url); | ||||||||||||||||||
| const html = await fetch(url).then((r) => r.text()); | ||||||||||||||||||
| const $ = load(html); | ||||||||||||||||||
|
Comment on lines
+65
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling and response validation to fetch call. Same issue as in Apply this diff to add proper error handling and response validation: - const html = await fetch(url).then((r) => r.text());
+ const res = await fetch(url);
+ if (!res.ok) {
+ throw new Error(`HTTP error! status: ${res.status}`);
+ }
+ const html = await res.text();Consider adding timeout handling for consistency: + const controller = new AbortController();
+ const timeoutId = setTimeout(() => controller.abort(), 30000);
+ try {
- const res = await fetch(url);
+ const res = await fetch(url, { signal: controller.signal });
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
const html = await res.text();
+ clearTimeout(timeoutId);
+ } catch (error) {
+ clearTimeout(timeoutId);
+ throw error;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| const selector = $('ol[id^="elTable"] .ipsDataItem'); | ||||||||||||||||||
| const page /** @type {PatchData[]} */ = []; | ||||||||||||||||||
|
|
@@ -191,7 +157,7 @@ class Scraper { | |||||||||||||||||
| * @returns {void} | ||||||||||||||||||
| */ | ||||||||||||||||||
| async #scrapePost(url, data) { | ||||||||||||||||||
| const html = await this.#fetch(url); | ||||||||||||||||||
| const html = await fetch(url).then((r) => r.text()); | ||||||||||||||||||
| const $ = load(html); | ||||||||||||||||||
|
Comment on lines
+160
to
161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling and response validation to fetch call. Same issue as in the other methods: the fetch call lacks error handling and response status validation. Apply this diff to add proper error handling and response validation: - const html = await fetch(url).then((r) => r.text());
+ const res = await fetch(url);
+ if (!res.ok) {
+ throw new Error(`HTTP error! status: ${res.status}`);
+ }
+ const html = await res.text();Consider adding timeout handling for consistency: + const controller = new AbortController();
+ const timeoutId = setTimeout(() => controller.abort(), 30000);
+ try {
- const res = await fetch(url);
+ const res = await fetch(url, { signal: controller.signal });
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
const html = await res.text();
+ clearTimeout(timeoutId);
+ } catch (error) {
+ clearTimeout(timeoutId);
+ throw error;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| const article = $('article').first(); | ||||||||||||||||||
| const post = article.find('div[data-role="commentContent"]'); | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling and response validation to fetch call.
The fetch call lacks error handling for network failures and doesn't validate the response status. Network errors or HTTP error responses (4xx, 5xx) will cause unhandled promise rejections or may result in parsing error pages as valid HTML.
Apply this diff to add proper error handling and response validation:
Additionally, consider adding timeout handling since the proxy-based timeout configuration was removed:
📝 Committable suggestion
🤖 Prompt for AI Agents