Skip to content
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

Reading FBBlob crashes when using manual transaction #116

Open
Kagu-chan opened this issue Jan 7, 2021 · 0 comments
Open

Reading FBBlob crashes when using manual transaction #116

Kagu-chan opened this issue Jan 7, 2021 · 0 comments

Comments

@Kagu-chan
Copy link

Following Code:

const { createConnection } = require('firebird');

const isFBBlob = (obj) => {
  return (
    obj &&
    typeof obj === 'object' &&
    'isReadable' in obj &&
    'inAsyncCall' in obj
  );
};

const con = createConnection();
con.connectSync(
  '127.0.0.1/3050:testdb',
  'sysdba',
  'masterkey',
  ''
);

const query = "SELECT AMSIDNR, INFO, GRUND FROM TERMIN WHERE AMSIDNR = ?;";
const args = [
  "ITE000000225314",
]

const obj = con;
// const obj = con.startNewTransactionSync();

const result = obj.prepareSync(query);

// result.execInTransSync(obj, ...(args || []));
result.execSync(...(args || []));

const res = result.fetchSync('all', true);

function getData(rows) {
  return Promise.all(
    rows.map(async row => {
      let key;
  
      for (key in row) {
        if (row[key]) {
          const val = row[key];
  
          if (isFBBlob(val)) {
            row[key] = await new Promise((resolve, reject) => {
              val._readAll((err, bf) => {
                if (err) {
                  reject(err);
                }
  
                resolve(bf);
              });
            });
          }
        }
      }
  
      return row;
    }),
  )
}

getData(res).then((rows) => {
  obj.commitSync();
  console.log(rows);
});

This code runs through just fine. In the sample here, the field INFO is a BLOB_SUBTYPE_TEXT.
As soon as i switch the lines 25 / 26 and 30 / 31 to use a manual created transaction, the code just stops and the process dies without a word.

After some testing i can say that the code crashes as soon as FBBlob._openSync() (index.js#L105 in this repo) is called - the same when trying to use the stream class (index.js#L162).

Is there (again #115 ) a method / parameter i missed or is this a limitation at any point?

image

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

1 participant