Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
22e33d04
Unverified
Commit
22e33d04
authored
4 months ago
by
Guilherme Gazzo
Committed by
GitHub
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
chore: handle imap errors (#33855)
parent
d4b3aefb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/meteor/server/email/IMAPInterceptor.ts
+24
-18
24 additions, 18 deletions
apps/meteor/server/email/IMAPInterceptor.ts
with
24 additions
and
18 deletions
apps/meteor/server/email/IMAPInterceptor.ts
+
24
−
18
View file @
22e33d04
...
...
@@ -57,6 +57,9 @@ export class IMAPInterceptor extends EventEmitter {
});
this
.
retries
=
0
;
this
.
inboxId
=
id
;
this
.
imap
.
on
(
'
error
'
,
async
(
err
:
Error
)
=>
{
logger
.
error
({
msg
:
'
IMAP error
'
,
err
});
});
void
this
.
start
();
}
...
...
@@ -88,8 +91,7 @@ export class IMAPInterceptor extends EventEmitter {
}
});
this
.
imap
.
on
(
'
error
'
,
async
(
err
:
Error
)
=>
{
logger
.
error
({
msg
:
'
IMAP error
'
,
err
});
this
.
imap
.
on
(
'
error
'
,
async
()
=>
{
this
.
retries
++
;
await
this
.
reconnect
();
});
...
...
@@ -106,6 +108,14 @@ export class IMAPInterceptor extends EventEmitter {
}
stop
(
callback
=
new
Function
()):
void
{
if
(
this
.
backoff
)
{
clearTimeout
(
this
.
backoff
);
this
.
backoffDurationMS
=
3000
;
}
this
.
stopWithNoStopBackoff
(
callback
);
}
private
stopWithNoStopBackoff
(
callback
=
new
Function
()):
void
{
logger
.
debug
(
'
IMAP stop called
'
);
this
.
imap
.
removeAllListeners
();
this
.
imap
.
once
(
'
end
'
,
()
=>
{
...
...
@@ -113,6 +123,9 @@ export class IMAPInterceptor extends EventEmitter {
callback
?.();
});
this
.
imap
.
end
();
this
.
imap
.
on
(
'
error
'
,
async
(
err
:
Error
)
=>
{
logger
.
error
({
msg
:
'
IMAP error
'
,
err
});
});
}
async
reconnect
():
Promise
<
void
>
{
...
...
@@ -121,26 +134,19 @@ export class IMAPInterceptor extends EventEmitter {
this
.
stop
();
return
this
.
selfDisable
();
}
if
(
this
.
backoff
)
{
clearTimeout
(
this
.
backoff
);
this
.
backoffDurationMS
=
3000
;
}
const
loop
=
async
():
Promise
<
void
>
=>
{
logger
.
debug
(
`Reconnecting to
${
this
.
config
.
user
}
:
${
this
.
retries
}
`
);
if
(
this
.
canRetry
())
{
this
.
backoffDurationMS
*=
2
;
this
.
backoff
=
setTimeout
(
loop
,
this
.
backoffDurationMS
);
}
else
{
logger
.
info
(
`IMAP reconnection failed on inbox
${
this
.
config
.
user
}
`
);
clearTimeout
(
this
.
backoff
);
this
.
stop
();
await
this
.
selfDisable
();
return
;
}
this
.
stop
();
await
this
.
start
();
};
this
.
backoff
=
setTimeout
(
loop
,
this
.
backoffDurationMS
);
this
.
backoff
=
setTimeout
(
()
=>
{
this
.
stopWithNoStopBackoff
();
void
this
.
start
();
},
(
this
.
backoffDurationMS
+=
this
.
backoffDurationMS
),
);
}
imapSearch
():
Promise
<
number
[]
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment