I would like to report a bug. Airtable javascript library has bad error handling when used with promises:
The following code demonstrates a wrong function call to table.create(). This function should be called with two parameters, and here I call it with one. Therefore, there should be some reasonable error message or the .catch section should be executed, but instead the program just hangs with the promise left unresolved forever.
At a later time, it would log an unclear warning UnhandledPromiseRejectionWarning. But the promise is still left unresolved.
Here is the sample code:
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'YOUR_API_KEY'}).base('YOUR_BASE_ID');
base('tablename').update({ "something": "wrong" })
.then( (record) => console.log("never gets here.", record))
.catch( (err) => console.error("never gets here neither", err) );
The full error message that appears in the log is:
(node:7969) UnhandledPromiseRejectionWarning: [object Object]
(node:7969) 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(). (rejection id: 3)