Skip to content

should the driver marshal iterable to array? #329

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

Closed
jasperblues opened this issue Feb 22, 2018 · 3 comments
Closed

should the driver marshal iterable to array? #329

jasperblues opened this issue Feb 22, 2018 · 3 comments

Comments

@jasperblues
Copy link

jasperblues commented Feb 22, 2018

send(): Promise<number> {
    return new Promise((resolve, reject) => {
        this.profiles()
            .then(profiles => Promise.all(profiles.map(it => this.sendWelcomeMail(it))))
            .then(users => {
                const params = {ids: users.map(it => it.id)};
                console.log('Got params: ' + JSON.stringify(params));
                return db.writeQueryAsync(`match (n:CandidateProfile) where n.id in {ids} 
                    set n.hasBeenWelcomed = true return count(n)`, params);
            })
            .then(result => resolve(result.data[0]))
            .catch(err => reject(err));
    });
}

Running the following code results in a parameters argument as follows:

{"ids":["a42b470b-5e19-4fce-934c-d9a634ac21d3","7c1e3d84-389f-481c-944e-efc2f7d76dad","5b8af43a-730f-482e-b7fe-5e6fbf9e91ee","ff1c33f1-fd98-4115-84b2-3780b425cb04","48023149-b8ee-4e34-be42-a4cae5d2b41e","063fed6c-b34b-4600-a043-0112c9eb87fd","d43037d8-e490-485b-b0b3-3ffb4c5df96d","3a113529-81df-4858-a1fd-8e7b4e5354e9","0353642d-e543-45db-8fdd-061a9b660c02","a9c9c34d-9b25-4a2b-b92d-547fc8b309b1"]}

The argument looks identical to me using either es6 or bluebird promise implementation, however with es6, an error is thrown:

Neo4jError: Property values can only be of primitive types or arrays thereof
    at new Neo4jError (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/error.js:76:132)
    at newError (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/error.js:66:10)
    at Connection._handleMessage (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/connector.js:355:56)
    at Dechunker.Connection._dechunker.onmessage (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/connector.js:286:12)
    at Dechunker._onHeader (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/chunking.js:246:14)
    at Dechunker.AWAITING_CHUNK (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/chunking.js:199:21)
    at Dechunker.write (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/chunking.js:257:28)
    at NodeChannel.self._ch.onmessage (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/connector.js:259:27)
    at TLSSocket.<anonymous> (/Users/jblues/vampr/vend_node/node_modules/neo4j-driver/lib/v1/internal/ch-node.js:308:16)
    at emitOne (events.js:115:13)

Not sure if this is helpful in its own right, will try to extract a public repo that demonstrates the problem asap.

@jasperblues
Copy link
Author

jasperblues commented Feb 22, 2018

Ah, adding Array.from(users.map(it => it.id)) works. Is it reasonable then to have the driver marshal iterable to an array?

@jasperblues jasperblues changed the title es6 Promise.all map fails, bluebird works should the driver marshal iterable to array? Feb 22, 2018
@lutovich
Copy link
Contributor

Hi @jasperblues,

I suppose driver could convert iterables to arrays. There is a possibility that given iterable is infinite which will make driver fail with OOM. Not sure if this is a real problem or no. Will create a card for us to investigate this.

@jasperblues
Copy link
Author

Awesome, looking forward to hear the outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants