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

Using NodeJS v22.11.0, the 'readdir' method does not return the 'mtime' field whatever the adbkit version 2.11.3 or 3.3.6!!! #536

Open
denis99999 opened this issue Nov 7, 2024 · 6 comments

Comments

@denis99999
Copy link

denis99999 commented Nov 7, 2024

###################################################### ADBKIT 2.11.3 ######################################################
---------------------------------------------------------------------------------------------------------------------------
$ nvm use 20.18.0
$ node
> adbkit = require('@devicefarmer/adbkit')
> adb = adbkit.createClient({host: '127.0.0.1', port: 5037})
> adb.readdir('FA6A90303673', '/').then(function(files) {console.log(files)})
> [
  Entry {
    name: 'product',
    mode: 41380,
    size: 15,
    mtime: 2009-01-01T00:00:00.000Z
  },
  Entry {
    name: 'res',
    mode: 16877,
    size: 4096,
    mtime: 2009-01-01T00:00:00.000Z
  },
  ...
]

RESULT => OK, "mtime" field is well present

---------------------------------------------------------------------------------------------------------------------------
$ nvm use 22.11.0
$ node
> adbkit = require('@devicefarmer/adbkit')
> adb = adbkit.createClient({host: '127.0.0.1', port: 5037})
> adb.readdir('FA6A90303673', '/').then(function(files) {console.log(files)})
> [
  Entry { name: 'product', mode: 41380, size: 15 },
  Entry { name: 'res', mode: 16877, size: 4096 },
  ...
]

RESULT => KO, "mtime" field is not present but no error raised

###################################################### ADBKIT 3.3.6 #######################################################
---------------------------------------------------------------------------------------------------------------------------
$ nvm use 20.18.0
$ node
> adbkit = require('@devicefarmer/adbkit')
> adb = adbkit.Adb.createClient({host: '127.0.0.1', port: 5037})
> device = adb.getDevice('FA6A90303673')
> device.readdir('/').then(function(res) {console.log('res:', res)}).catch(function(error) {console.log('error:', error)})
> res: [
  Entry {
    dev: undefined,
    mode: 41380,
    nlink: undefined,
    uid: undefined,
    gid: undefined,
    rdev: undefined,
    blksize: undefined,
    ino: undefined,
    size: 15,
    blocks: undefined,
    atimeMs: undefined,
    mtimeMs: undefined,
    ctimeMs: undefined,
    birthtimeMs: undefined,
    atime: Invalid Date,
    mtime: 2009-01-01T00:00:00.000Z,
    ctime: Invalid Date,
    birthtime: Invalid Date,
    sizeBig: 15n,
    name: 'product'
  },
  Entry {
    dev: undefined,
    mode: 16877,
    nlink: undefined,
    uid: undefined,
    gid: undefined,
    rdev: undefined,
    blksize: undefined,
    ino: undefined,
    size: 4096,
    blocks: undefined,
    atimeMs: undefined,
    mtimeMs: undefined,
    ctimeMs: undefined,
    birthtimeMs: undefined,
    atime: Invalid Date,
    mtime: 2009-01-01T00:00:00.000Z,
    ctime: Invalid Date,
    birthtime: Invalid Date,
    sizeBig: 4096n,
    name: 'res'
  },
  ...
]

RESULTAT => OK, "mtime" field is well present

---------------------------------------------------------------------------------------------------------------------------
$ nvm use 22.11.0
$ node --trace-deprecation
> adbkit = require('@devicefarmer/adbkit')
> adb = adbkit.Adb.createClient({host: '127.0.0.1', port: 5037})
> device = adb.getDevice('FA6A90303673')
> device.readdir('/').then(function(res) {console.log('res:', res)}).catch(function(error) {console.log('error:', error)})
> res: [
  Entry {
    dev: undefined,
    mode: 41380,
    nlink: undefined,
    uid: undefined,
    gid: undefined,
    rdev: undefined,
    blksize: undefined,
    ino: undefined,
    size: 15,
    blocks: undefined,
    atimeMs: undefined,
    mtimeMs: undefined,
    ctimeMs: undefined,
    birthtimeMs: undefined,
    sizeBig: 15n,
    name: 'product'
  },
  Entry {
    dev: undefined,
    mode: 16877,
    nlink: undefined,
    uid: undefined,
    gid: undefined,
    rdev: undefined,
    blksize: undefined,
    ino: undefined,
    size: 4096,
    blocks: undefined,
    atimeMs: undefined,
    mtimeMs: undefined,
    ctimeMs: undefined,
    birthtimeMs: undefined,
    sizeBig: 4096n,
    name: 'res'
  },
  ...
]
(node:3796) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
    at new Stats (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/dist/src/adb/sync/stats.js:29:9)
    at new Entry (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/dist/src/adb/sync/entry.js:8:9)
    at /home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/dist/src/adb/sync.js:122:48
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at tryCatcher (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/home/debian/GITHUB/DENIS99999/stf/node_modules/@devicefarmer/adbkit/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:491:21)
    at process.topLevelDomainCallback (node:domain:161:15)

RESULT => KO, "mtime" field is not present + DeprecationWarning: fs.Stats constructor is deprecated

I haven't done full testing of adbkit using NodeJS version 22.11.3 but there are probably other similar issues, is it possible to quickly update the adbkit code to comply with the latest versions of NodeJS in order to allow applications that use adbkit (e.g. STF, ...) to work correctly?
Thanks.

@koral--
Copy link
Member

koral-- commented Nov 7, 2024

Could you submit a PR?

@denis99999
Copy link
Author

@koral-- the @devicefarmer/adbkit contains only the 3.x versions, where is the 2.11.3 version to fix the bug ?

@koral--
Copy link
Member

koral-- commented Nov 8, 2024

There is a tag for it: https://github.com/DeviceFarmer/adbkit/tree/v2.11.3

@denis99999
Copy link
Author

Sorry, it was obvious!
I forked the repository and I created a branch locally, in the package.json file I redirected the adbkit path locally, as I made for other packages in dev mode, but this adbkit v2.11.3 is written in coffee script and after the build the run raised an error: Cannot find module '[..]stf/node_modules/@devicefarmer/adbkit/index'. Please verify that the package.json has a valid "main" entry, this is because in the index.coffee file (module.exports = require './lib/adb') the module is not found because the lib folder does not exist, how generate the missing files for the run ?

@koral--
Copy link
Member

koral-- commented Nov 8, 2024

I've checked out that tag, invoked npm install using node v23.1.0 without any modifications and the lib folder was generated. bin/adbkit executes without errors.

If lib is not created on your machine, it seems that your modification may broke something. Was npm install successful with your changes?

@denis99999
Copy link
Author

Yes it works now!
I fixed the issue, I will submit a PR quickly both for v2.11.3 and v3.3.6!

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

2 participants