@@ -15,7 +15,7 @@ const runCommand = require('../../../utils/run-command');
1515 * Helper to determine if any file exists in an array of files.
1616 *
1717 * @param {Array<string> } files - Array of file paths to check.
18- * @returns {boolean }
18+ * @return {boolean }
1919 * @private
2020 */
2121const srcExists = ( files = [ ] ) => _ . reduce ( files , ( exists , file ) => fs . existsSync ( file ) || exists , false ) ;
@@ -33,7 +33,7 @@ const srcExists = (files = []) => _.reduce(files, (exists, file) => fs.existsSyn
3333 * - Labels whose values contain `,` within values that also contain `=`
3434 *
3535 * @param {string|Object } labels - Labels string from nerdctl or object from inspect.
36- * @returns {Object } Docker-compatible labels object.
36+ * @return {Object } Docker-compatible labels object.
3737 * @private
3838 */
3939const parseLabels = labels => {
@@ -91,7 +91,7 @@ const parseLabels = labels => {
9191 * - `Status` → status text
9292 *
9393 * @param {Object } nerdctlContainer - A parsed JSON line from `nerdctl ps --format json`.
94- * @returns {Object } Docker API-compatible container object.
94+ * @return {Object } Docker API-compatible container object.
9595 * @private
9696 */
9797const normalizeContainer = nerdctlContainer => {
@@ -164,7 +164,7 @@ class ContainerdContainer extends ContainerBackend {
164164 * "No such container", "no such object", "not found".
165165 *
166166 * @param {Error } err - The error to inspect.
167- * @returns {boolean } `true` if the error indicates a missing resource.
167+ * @return {boolean } `true` if the error indicates a missing resource.
168168 * @private
169169 */
170170 _isNotFoundError ( err ) {
@@ -184,7 +184,7 @@ class ContainerdContainer extends ContainerBackend {
184184 * @param {Array<string> } args - nerdctl subcommand and arguments.
185185 * @param {Object } [opts={}] - Additional options passed to `run-command`.
186186 * @param {boolean } [opts.ignoreReturnCode=false] - Whether to suppress non-zero exit errors.
187- * @returns {Promise<string> } The trimmed stdout from the command.
187+ * @return {Promise<string> } The trimmed stdout from the command.
188188 * @throws {Error } If the command exits non-zero and `ignoreReturnCode` is false.
189189 * @private
190190 */
@@ -216,7 +216,7 @@ class ContainerdContainer extends ContainerBackend {
216216 *
217217 * @param {string } name - The name of the network to create.
218218 * @param {Object } [opts={}] - Additional network creation options.
219- * @returns {Promise<Object> } Network inspect data.
219+ * @return {Promise<Object> } Network inspect data.
220220 */
221221 async createNet ( name , opts = { } ) {
222222 const args = [ 'network' , 'create' ] ;
@@ -254,7 +254,7 @@ class ContainerdContainer extends ContainerBackend {
254254 * Docker-compatible JSON.
255255 *
256256 * @param {string } cid - A container identifier (hash, name, or short id).
257- * @returns {Promise<Object> } Container inspect data.
257+ * @return {Promise<Object> } Container inspect data.
258258 * @throws {Error } If the container does not exist.
259259 */
260260 async scan ( cid ) {
@@ -270,7 +270,7 @@ class ContainerdContainer extends ContainerBackend {
270270 * to prevent race conditions when containers are removed between checks.
271271 *
272272 * @param {string } cid - A container identifier.
273- * @returns {Promise<boolean> }
273+ * @return {Promise<boolean> }
274274 */
275275 async isRunning ( cid ) {
276276 try {
@@ -303,9 +303,10 @@ class ContainerdContainer extends ContainerBackend {
303303 * @param {string } [options.project] - Filter to a specific project name.
304304 * @param {Array<string> } [options.filter] - Additional `key=value` filters.
305305 * @param {string } [separator='_'] - Container name separator.
306- * @returns {Promise<Array<Object>> } Array of Lando container descriptors.
306+ * @param {number } [_retryCount=0] - Internal retry counter to prevent unbounded recursion.
307+ * @return {Promise<Array<Object>> } Array of Lando container descriptors.
307308 */
308- async list ( options = { } , separator = '_' ) {
309+ async list ( options = { } , separator = '_' , _retryCount = 0 ) {
309310 // Get raw container list from nerdctl (JSONL: one JSON object per line)
310311 let rawOutput ;
311312 try {
@@ -380,7 +381,10 @@ class ContainerdContainer extends ContainerBackend {
380381 // If any container has been up for only a brief moment, retry
381382 // (matches Landerode behavior to avoid transient states)
382383 if ( _ . find ( containers , container => container . status === 'Up Less than a second' ) ) {
383- return this . list ( options , separator ) ;
384+ if ( _retryCount < 10 ) {
385+ return this . list ( options , separator , _retryCount + 1 ) ;
386+ }
387+ this . debug ( 'list retry limit reached, proceeding with transient container states' ) ;
384388 }
385389
386390 // Add running status flag
@@ -401,7 +405,7 @@ class ContainerdContainer extends ContainerBackend {
401405 * @param {Object } [opts={v: true, force: false}] - Removal options.
402406 * @param {boolean } [opts.v=true] - Also remove associated anonymous volumes.
403407 * @param {boolean } [opts.force=false] - Force-remove a running container.
404- * @returns {Promise<void> }
408+ * @return {Promise<void> }
405409 */
406410 async remove ( cid , opts = { v : true , force : false } ) {
407411 const args = [ 'rm' ] ;
@@ -428,7 +432,7 @@ class ContainerdContainer extends ContainerBackend {
428432 *
429433 * @param {string } cid - A container identifier.
430434 * @param {Object } [opts={}] - Stop options (e.g. `{t: 10}` for timeout in seconds).
431- * @returns {Promise<void> }
435+ * @return {Promise<void> }
432436 */
433437 async stop ( cid , opts = { } ) {
434438 const args = [ 'stop' ] ;
@@ -458,7 +462,7 @@ class ContainerdContainer extends ContainerBackend {
458462 * handle interface.
459463 *
460464 * @param {string } id - The network id or name.
461- * @returns {Object } A network handle with `inspect()` and `remove()` methods.
465+ * @return {Object } A network handle with `inspect()` and `remove()` methods.
462466 */
463467 getNetwork ( id ) {
464468 return {
@@ -467,7 +471,7 @@ class ContainerdContainer extends ContainerBackend {
467471
468472 /**
469473 * Inspect the network and return its metadata.
470- * @returns {Promise<Object> } Network inspect data.
474+ * @return {Promise<Object> } Network inspect data.
471475 */
472476 inspect : async ( ) => {
473477 const data = await this . _nerdctl ( [ 'network' , 'inspect' , id ] ) ;
@@ -477,7 +481,7 @@ class ContainerdContainer extends ContainerBackend {
477481
478482 /**
479483 * Remove the network.
480- * @returns {Promise<void> }
484+ * @return {Promise<void> }
481485 */
482486 remove : async ( ) => {
483487 try {
@@ -498,7 +502,7 @@ class ContainerdContainer extends ContainerBackend {
498502 *
499503 * @param {Object } [opts={}] - Filter options.
500504 * @param {Object } [opts.filters] - Filters object (e.g. `{name: ['mynet']}` or `{id: ['abc']}`).
501- * @returns {Promise<Array<Object>> } Array of network objects.
505+ * @return {Promise<Array<Object>> } Array of network objects.
502506 */
503507 async listNetworks ( opts = { } ) {
504508 let rawOutput ;
@@ -565,7 +569,7 @@ class ContainerdContainer extends ContainerBackend {
565569 * Dockerode Container handle interface.
566570 *
567571 * @param {string } cid - The container id or name.
568- * @returns {Object } A container handle with `inspect()`, `remove()`, and `stop()` methods.
572+ * @return {Object } A container handle with `inspect()`, `remove()`, and `stop()` methods.
569573 */
570574 getContainer ( cid ) {
571575 return {
@@ -574,21 +578,21 @@ class ContainerdContainer extends ContainerBackend {
574578
575579 /**
576580 * Inspect the container and return its metadata.
577- * @returns {Promise<Object> } Container inspect data.
581+ * @return {Promise<Object> } Container inspect data.
578582 */
579583 inspect : ( ) => this . scan ( cid ) ,
580584
581585 /**
582586 * Remove the container.
583587 * @param {Object } [opts] - Removal options.
584- * @returns {Promise<void> }
588+ * @return {Promise<void> }
585589 */
586590 remove : opts => this . remove ( cid , opts ) ,
587591
588592 /**
589593 * Stop the container.
590594 * @param {Object } [opts] - Stop options.
591- * @returns {Promise<void> }
595+ * @return {Promise<void> }
592596 */
593597 stop : opts => this . stop ( cid , opts ) ,
594598 } ;
0 commit comments