Comments (6)
This seems to happen when node
is a Date
.
from wildduck.
@andris9 see #619, we wrapped the switch
statement with a conditional of if (typeof node?.type === 'string') {
from wildduck.
How do you have a Date object as the node? This is not a supported value for the response compiler.
from wildduck.
@andris9 Hi there 👋 We debugged this and here's what we came up with:
First, we invoke WildDuck's prepareMessage
function with the options { flags, date, raw }
:
{
flags: [],
date: 2024-02-09T17:20:55.421Z,
raw: <Buffer 44 61 74 65 3a 20 32 30 32 34 2d 30 32 2d 30 39 54 31 37 3a 32 30 3a 35 35 2e 34 32 31 5a 0a 4d 49 4d 45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0a 43 ... 197 more bytes>
}
The mime tree then gets parsed via let mimeTree = options.mimeTree || this.indexer.parseMimeTree(options.raw);
:
{
header: [
'Date: 2024-02-09T17:20:55.421Z',
'MIME-Version: 1.0',
'Content-Language: en-US',
'To: [email protected]',
'From: [email protected]',
'Subject: 2f46c154-efd0-4c4e-ac7f-079e6cd50200',
'Content-Type: text/plain; charset=UTF-8; format=flowed',
'Content-Transfer-Encoding: 7bit'
],
parsedHeader: {
'content-transfer-encoding': '7bit',
'content-type': {
value: 'text/plain',
type: 'text',
subtype: 'plain',
params: [Object],
hasParams: true
},
subject: '2f46c154-efd0-4c4e-ac7f-079e6cd50200',
from: [ [Object] ],
to: [ [Object] ],
'content-language': 'en-US',
'mime-version': '1.0',
date: '2024-02-09T17:20:55.421Z'
},
body: <Buffer 74 65 73 74>,
multipart: false,
boundary: false,
lineCount: 0,
size: 4
}
Then the returned envelope object parsed via let envelope = this.indexer.getEnvelope(mimeTree);
like this:
[
'2024-02-09T17:20:55.421Z',
<Buffer 32 66 34 36 63 31 35 34 2d 65 66 64 30 2d 34 63 34 65 2d 61 63 37 66 2d 30 37 39 65 36 63 64 35 30 32 30 30>,
[
[
null,
null,
<Buffer 62 65 65 70>,
<Buffer 62 65 65 70 2e 63 6f 6d>
]
],
[
[
null,
null,
<Buffer 62 65 65 70>,
<Buffer 62 65 65 70 2e 63 6f 6d>
]
],
[
[
null,
null,
<Buffer 62 65 65 70>,
<Buffer 62 65 65 70 2e 63 6f 6d>
]
],
[ [ null, null, <Buffer 66 6f 6f>, <Buffer 66 6f 6f 2e 63 6f 6d> ] ],
null,
null,
null,
null
]
This is all OK. However we store it in SQLite and when it gets parsed/fetched again, the string looks like a date, so it gets converted to a Date
. This is the culprit for the issue (totally on our side, but might be nice to have dummy-proofing it's a date to convert to a string, in case someone else has a similar approach).
from wildduck.
We've fixed this on our side already, feel free to close unless you decide it's worth having a conditional check for node.type
as a Date
and convert to string via toISOString()
:
//
// NOTE: this is an edge case because of how we store envelopes
// <https://github.com/nodemailer/wildduck/issues/618#issuecomment-1933139110>
//
value = message.envelope.map((a) =>
a instanceof Date ? a.toISOString() : a
);
Note the code above is our adaptation from getQueryResponse
:
case 'envelope': {
if (message.envelope) {
- value = message.envelope;
+ //
+ // NOTE: this is an edge case because of how we store envelopes
+ // <https://github.com/nodemailer/wildduck/issues/618#issuecomment-1933139110>
+ //
+ value = message.envelope.map((a) =>
+ a instanceof Date ? a.toISOString() : a
+ );
// cast invalidly stored In-Reply-To (8) and Message-ID (9) to strings
for (const index of [9, 10]) {
if (value[index] && Array.isArray(value[index])) {
from wildduck.
Thanks for the explanation. I'd prefer less magic here, and I think it is good to have an exception when parsing internal structures with expected values - helps to detect problems sooner. I'd also suggest not labelling issues as "core bugs" unless you have a reproducible test case, otherwise the issue can be overlooked even if it identifies a real problem.
from wildduck.
Related Issues (20)
- Bug: Content encoding is incorrect HOT 16
- Bug: Messages being saved to drafts folder do not get rendered in mail clients due to ignored message HOT 2
- Bug: mimeTree rebuilding does not join boundaries by a line break delimiter (e.g. `\r\n`) HOT 6
- Mail thread HOT 4
- What are all the steps needed to config WildDuck'a API to use X-Access-Token? HOT 18
- install script is installing wildduck 1.39.14 HOT 1
- Feat: Thoughts on `encryptMessageAsync` also adding an attachment of `public-key.pgp.asc`? HOT 1
- GET /users/{user}/search or.query parameter bug HOT 1
- Bug: Odd edge case bug `TypeError: Cannot set properties of null (setting 'user')` HOT 2
- Updating/Upgrading existing server HOT 2
- SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports HOT 1
- Moving OLD unsecure mechanisms to Historic HOT 5
- Threading doesn't account for prefixes some mail systems or clients add HOT 2
- Deleting hidden mailbox HOT 3
- Question on support for `SORT (DATE) US-ASCII ALL` command HOT 1
- Bug: `Unexpected end of input at position 53` and `Invalid tag` tag errors (using Mozilla Thunderbird to copy sent message to Sent Mail folder) HOT 7
- Feature request: POP3 server does not invoke `releaseConnection` as similar to IMAP server (thus connection counts/rate limiting cannot be accurate) HOT 3
- Multi MTA with Domain Responsibility HOT 1
- Bug: `TypeError: connection._server.options.SNICallback is not a function` HOT 7
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 wildduck.