mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-08-15 10:49:44 +02:00
Merge branch 'beta' into refactor
This commit is contained in:
@ -8,10 +8,10 @@
|
||||
const SERVER_STATE_VALIDITY_DURATION = 90 * 1000 // ms - 90 seconds to allow ping to timeout more than once before killing tasks.
|
||||
const HEALTH_PING_INTERVAL = 5000 // ms
|
||||
const IDLE_COOLDOWN = 2500 // ms
|
||||
const CONCURRENT_TASK_INTERVAL = 500 // ms
|
||||
const CONCURRENT_TASK_INTERVAL = 100 // ms
|
||||
|
||||
/** Connects to an endpoint and resumes connexion after reaching end of stream until all data is received.
|
||||
* Allows closing the connexion while the server buffers more data.
|
||||
/** Connects to an endpoint and resumes connection after reaching end of stream until all data is received.
|
||||
* Allows closing the connection while the server buffers more data.
|
||||
*/
|
||||
class ChunkedStreamReader {
|
||||
#bufferedString = '' // Data received waiting to be read.
|
||||
@ -264,11 +264,11 @@
|
||||
|
||||
function isServerAvailable() {
|
||||
if (typeof serverState !== 'object') {
|
||||
console.error('serverState not set to a value. Connexion to server could be lost...')
|
||||
console.error('serverState not set to a value. Connection to server could be lost...')
|
||||
return false
|
||||
}
|
||||
if (Date.now() >= serverState.time + SERVER_STATE_VALIDITY_DURATION) {
|
||||
console.warn('SERVER_STATE_VALIDITY_DURATION elapsed. Connexion to server could be lost...')
|
||||
console.warn('SERVER_STATE_VALIDITY_DURATION elapsed. Connection to server could be lost...')
|
||||
return false
|
||||
}
|
||||
switch (serverState.status) {
|
||||
@ -306,7 +306,7 @@
|
||||
if (await healthCheck() && isServerAvailable()) { // Force a recheck of server status before failure...
|
||||
continue // Continue waiting if last healthCheck confirmed the server is still alive.
|
||||
}
|
||||
throw new Error('Connexion with server lost.')
|
||||
throw new Error('Connection with server lost.')
|
||||
}
|
||||
}
|
||||
if (Date.now() >= serverState.time + SERVER_STATE_VALIDITY_DURATION) {
|
||||
@ -837,6 +837,8 @@
|
||||
* @memberof Task
|
||||
*/
|
||||
async post(timeout=-1) {
|
||||
performance.mark('make-render-request')
|
||||
console.log('delay between clicking and making the server request:', performance.measure('diff', 'click-makeImage', 'make-render-request').duration + ' ms')
|
||||
let jsonResponse = await super.post('/render', timeout)
|
||||
if (typeof jsonResponse?.task !== 'number') {
|
||||
console.warn('Endpoint error response: ', jsonResponse)
|
||||
@ -1104,9 +1106,9 @@
|
||||
idleEventPromise = makeQuerablePromise(eventSource.fireEvent(EVENT_IDLE, {capacity: serverCapacity, idle: true}))
|
||||
}
|
||||
// Calling idle could result in task being added to queue.
|
||||
if (task_queue.size <= 0 && concurrent_generators.size <= 0) {
|
||||
return asyncDelay(IDLE_COOLDOWN).then(() => idleEventPromise)
|
||||
}
|
||||
// if (task_queue.size <= 0 && concurrent_generators.size <= 0) {
|
||||
// return asyncDelay(IDLE_COOLDOWN).then(() => idleEventPromise)
|
||||
// }
|
||||
}
|
||||
if (task_queue.size < serverCapacity) {
|
||||
if (!idleEventPromise?.isPending) {
|
||||
|
Reference in New Issue
Block a user