solr-node-client: UnhandledPromiseRejectionWarning Error
Hello All,
I’m using Node 14 and seem to be running into this error when adding simple test data to solr
:
const solr = require('solr-client');
const client = solr.createClient();
client.add({ id: 12, title_t: 'Hello' }, function(err, obj) {
if (err) {
console.log(err);
} else {
console.log('Solr response:', obj);
}
}
(node:39116) UnhandledPromiseRejectionWarning: Error: Request HTTP error 404:
at Client.doRequest (…/node_modules/solr-client/dist/lib/solr.js:141:19)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ...
to show where the warning was created)
(node:39116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:39116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Appreciate any help. Thank you
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16
@ranrao Do you use Docker? This is how we init Solr Docker image:
Alternatively see this: https://www.tutorialspoint.com/apache_solr/apache_solr_core.htm
Thank you @kibertoad. Tried creating a Solr core and it is all working very well now. Such timely help. Really appreciate it.
@ranrao Updated most important examples in
examples
directory as well as readme.Let me update the sample.
@ranrao Ah, that explains it. You are trying using it with callback API which is no longer supported. Remove the callback parameter and just await this call.
I would strongly recommend giving latest RC version a try. It uses a much friendlier promise API that should be easier to consume. Main reason why it’s not final yet is because we still need to update documentation, but it should be pretty stable and ready for production (and actually significantly more performant than the current stable version).