Comments (10)
Okay, I made a handler for the promise and will keep investigating what made the request go wrong.
I published new release, please check the package's new version.
from node-hitomi.
Since the request problem wasn't solved, I guess it's fine to keep this issue open.
Just let me investigate this problem's cause.
from node-hitomi.
Hmm... I couldn't find any problems with tests on various node versions.
Have you checked your internet connection? (Or perhaps Hitomi's server could have gone down while you writing that code)
from node-hitomi.
which function made a request for https://ltn.hitomi.la/gg.js
?
I'd like to try something with try-catch, can you tell me which one?
from node-hitomi.
Since the data of that page is related to generating the image url, synchronize
method of ImageUrlResolver
instance makes a request.
Additionally, I want you to check if you can access that page manually with your browser or something.
Sorry that I couldn't be of any help, I hope you find out the problem.
from node-hitomi.
.catch
didnt work. The error bleeds to the process.
const getImageUrl = async function getImageUrl(image: hitomiType.Image, extension: "avif" | "webp", options: { isThumbnail?: boolean | undefined; isSmall?: boolean | undefined; }) {
if (!IUR) {
const hitomi: typeof hitomiType = require("node-hitomi").default;
IUR = new hitomi.ImageUrlResolver();
await IUR.synchronize().catch((err: Error) => {
console.log("Error catch from synchronize");
console.log(err.message);
}); // first synchronize
}
return await IUR.getImageUrl(image, extension, options);
}
// ...
CPM.registerJob("hitomi:startup", () => {
setInterval(() => {
if (IUR) IUR.synchronize().catch(
(err: Error) => {
console.log("Error catch from synchronize");
console.log(err.message);
});
}, SynchronizeInterval);
});
console:
HitomiError [REQEUST_REJECTED]: Request to 'https://ltn.hitomi.la/gg.js' was rejected
at ClientRequest.<anonymous> (<omitted>\node_modules\node-hitomi\library\index.js:1:2451)
at ClientRequest.emit (node:events:527:28)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'REQEUST_REJECTED'
}
To be clear, I'm able to access hitomi.la without any problem, and my app was able to fetch some image before the error was thrown.
CPH: Assigning "hitomi:download" job to child process #2
TOKYO NECRO SUICIDE MISSION R downloaded 0
CPH: Assigning "hitomi:download" job to child process #3
TOKYO NECRO SUICIDE MISSION R downloaded 1
CPH: Assigning "hitomi:download" job to child process #4
TOKYO NECRO SUICIDE MISSION R downloaded 2
CPH: Assigning "hitomi:download" job to child process #5
TOKYO NECRO SUICIDE MISSION R downloaded 3
CPH: Assigning "hitomi:download" job to child process #6
I was also able to access https://ltn.hitomi.la/gg.js
on my browser.
I'll try with try-catch
statement for now, hopefully the error doesn't bleed to the process.
from node-hitomi.
Nope, try-catch
didn't work either
const getImageUrl = async function getImageUrl(image: hitomiType.Image, extension: "avif" | "webp", options: { isThumbnail?: boolean | undefined; isSmall?: boolean | undefined; }) {
if (!IUR) {
const hitomi: typeof hitomiType = require("node-hitomi").default;
IUR = new hitomi.ImageUrlResolver();
try {
await IUR.synchronize().catch((err: Error) => {
console.log("Error catch from synchronize");
console.log(err.message);
}); // first synchronize
}
catch (err) {
console.log("Error catch from try-catch synchronize");
console.log(err.message);
}
}
return await IUR.getImageUrl(image, extension, options);
}
CPM.registerJob("hitomi:startup", () => {
setInterval(() => {
if (IUR) {
try {
IUR.synchronize().catch(
(err: Error) => {
console.log("Error catch from synchronize");
console.log(err.message);
});
}
catch (err) {
console.log("Error catch from try-catch synchronize");
console.log(err.message);
}
}
}, SynchronizeInterval);
});
Same error, not going to post it again here to avoid spamming
from node-hitomi.
I believe the most important thing to fix here is the fact that the error can't be catch on both .catch
and try-catch
statement.
Because it somehow immediately broke my loop (the code was run in for
loop, but the .synchronize()
was in interval of every 10 minutes)
from node-hitomi.
I suggest to add .catch()
here:
Code:
IUR.synchronize().catch(err => { console.log("Catched an error from synchronize: ", err); return Promise.reject(err) });
Console:
Catched an error from synchronize: HitomiError [REQEUST_REJECTED]: Request to 'https://ltn.hitomi.la/gg.js' was rejected
at ClientRequest.<anonymous> (<omitted>\node_modules\node-hitomi\library\index.js:2:1747)
at ClientRequest.emit (node:events:527:28)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'REQEUST_REJECTED'
}
CPM: Downloader error on undefined:
Only absolute URLs are supported
Error on downloading 4
HitomiError [REQEUST_REJECTED]: Request to 'https://ltn.hitomi.la/gg.js' was rejected
at ClientRequest.<anonymous> (<omitted>\node_modules\node-hitomi\library\index.js:2:1747)
at ClientRequest.emit (node:events:527:28)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Retrying...
Notice that after the error was catched, the loop continues and it retries the operation.
Although idk why the error was logged twice, but hey it works and doesn't breaks the loop.
Edit: nvm, the error was logged twice because the root caller was also logging the error on Promise reject.
from node-hitomi.
Okay, the error now can be catched
Should I leave this issue open? because although the error can be catched now, it doesn't actually solve the main problem
from node-hitomi.
Related Issues (20)
- Handle long gallery title
- Add Support for "cg" type of galllery HOT 4
- Apply popularized code style
- HitomiError [REQEUST_REJECTED]: Request to 'https://ltn.hitomi.la/index-all.nozomi' was rejected
- Improve performance of array related function
- Make getQueriedIds more efficient HOT 1
- getImageUrl is throwing 403 HOT 6
- Make method to get image url flexible
- Merge getIds and getQuriedIds
- Make getTags work properly
- When use 'getIds' or 'getQueriedIds', throw REQUEST_REJECTED HOT 2
- Add gallery related data to Gallery HOT 1
- Add text search to getIds function
- Subdomain mismatch on the url of the image HOT 15
- Hitomi only supports extension of webp, avif, jxl and mp4 only from now on HOT 10
- 403 for image url created using getImageUrl
- getTags with artist(and group, series, character), return blank array HOT 2
- getTags can't find artists include dot character HOT 2
- 403 Error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-hitomi.