question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'offset' of undefined

See original GitHub issue

Issue Description

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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:21

github_iconTop GitHub Comments

11reactions
bfagundezcommented, May 2, 2021

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();
          }
        }
      );
6reactions
Swiftivescommented, May 28, 2021

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);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'offset' of undefined
I am getting Uncaught TypeError: Cannot read property 'offset' of undefined. Before that i was getting same exception for 'top' from same ...
Read more >
Cannot read property 'offset' of undefined - Airtable Community
Hi, I am trying to load all rows of a base. The code I use is: const airbase = airtable.base('XXXXXXXX').table('someTable') await.
Read more >
TypeError: Cannot read property 'offset' of undefined - jQWidgets
I'm getting the error TypeError: Cannot read property 'offset' of undefined but I don't know why…. My JSON is valid and looks like...
Read more >
TypeError: Cannot read property 'top' of Undefined in JS
To resolve the "Cannot read property 'top' of undefined" error, make sure that the DOM element you're accessing the top property on exists....
Read more >
Uncaught TypeError: Cannot read property 'offset' of undefined
Uncaught TypeError: Cannot read property 'offset' of undefined ; = new Vector3 ; follow · offset. ; follow · offset. ; follow ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

Airtable returns not all records via API - Stack Overflow
Read More >

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found