airtable.js: TypeError: Cannot read property 'offset' of undefined

It seems that if some cells are empty, the select() method fails with the following error:

TypeError: Cannot read property 'offset' of undefined
at /node_modules/airtable/lib/query.js:109:28
at /node_modules/airtable/lib/run_action.js:70:17

This prevents all the other records to be read, so it is a pretty impacting issue. The library should just keep the empty value as an empty string or null or undefined. I.e. anything that does not crash.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 11
  • Comments: 24

Most upvoted comments

I’ve seen this recently. It’s probably due to an error inside of the eachPage function. Try wrapping that into a try/catch :

ATBase("Items")
      .select({
        view: "Grid view"
      })
      .eachPage(
        function page(records, fetchNextPage) {
         try {
          records.forEach(function(record) {
            myArr.push({
              id: record.id,
              ...record._rawJson.fields
            });
          });
          } catch(e){ console.log('error inside eachPage => ',e)}
          fetchNextPage();
        },
        function done(err) {
          if (err) {
            console.error(err);
          } else {
            callback();
          }
        }
      );

Hello! You guys! This happens because the page tries to fetch the next nonexistent page, fix by:

          Base('Training Booked')
            .select({

                fields : ['Type of Training', 'Date & Time of Host'],
                filterByFormula :`AND(NOT(Confirmed), Token = '${Token}')`,


            }).eachPage( function page(records, next) {

                    records.forEach(function(rec) {

                        try {

                            ToReturn.push(rec)

                        } catch (err) {

                            console.error(err);

                        }

                    })

                    try { // HERE

                        next();

                    } catch { return; }

            }, function (err) {
                if (err) {

                    console.error(err);

                    rej(err.statusCode);
                    return;

                }

                acpt(ToReturn);

getting the same thing on a new created DB

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'offset')
    at query.js:160:20
    at run_action.js:84:9

curl, and using fetch works without any errors so it must be something about the Airtable library, the DB contains 27 records, I’ve tried to pull 10, 20, 27, 100 but it always gives the same error. Using the try ... catch solution above didn’t work.

had this issue too (I’m downloading over 100,000 records). I found that adding a a few hundred millisecond sleep/wait after each page solved the issue - so this might be a rate limiting thing as one of the causes