Coder Social home page Coder Social logo

Comments (4)

kukhariev avatar kukhariev commented on July 20, 2024

I tried this code:

  • express 4.17.1:
const options = new DiskStorage({
  directory: 'upload'
});
app.use('/upload/files', uploadx.upload(options), (req, res) => {
  res.sendStatus(500);
});
  • modified app/service-code-way/service-code-way.component.ts, angular 11.2.7 , build --prod:
@Component({
  selector: 'app-service-way',
  templateUrl: './service-code-way.component.html'
})
export class ServiceCodeWayComponent implements OnDestroy, OnInit {
  state$!: Observable<UploadState>;
  uploads: Ufile[] = [];
  numberOfCopies = 0;
  @ViewChild('file', { read: ElementRef })
  fileInput!: ElementRef;

  private unsubscribe$ = new Subject();

  constructor(private uploadService: UploadxService) {}
  onChange(): void {
    const files = this.fileInput.nativeElement.files;
    for (let i = 0; i < files.length; i++) {
      this.uploadService.handleFiles(files[i], {
        endpoint: `${environment.api}/upload/files`,
        multiple: false,
        token: 'token'
      });
    }
  }

  ngOnInit(): void {
    this.state$ = this.uploadService.init();
    this.state$.pipe(takeUntil(this.unsubscribe$)).subscribe(state => {
      const file = this.uploads.find(item => item.uploadId === state.uploadId);
      file ? file.update(state) : this.uploads.push(new Ufile(state));
    });
  }
...

Couldn't catch the error.
8 retry attempts or 5 retries if i set retryConfig: { maxAttempts: 5 }

sendFileContent() and getOffset() should always reject at code 500.

Only In uploader-examples\multipart-form-data.ts a similar error is possible.

from ngx-uploadx.

kontrollanten avatar kontrollanten commented on July 20, 2024

Sorry, I wasn't clear enough. The issue appears when a 500 is returned when the file upload is completed.

from ngx-uploadx.

kukhariev avatar kukhariev commented on July 20, 2024

I don't get endless attempts.
2021-04-16_21-01-56

Is it possible to test with this server code (with correct PATH and PORT)?

const express = require('express');
const { uploadx } = require('node-uploadx');
//
const PATH = '/api/v1/videos/upload';
const PORT = 3003;
//
const app = express();
let retries = 0;
app.use(PATH, uploadx.upload({ directory: 'upload' }), (req, res) => {
  return res.status(500).json({ message: `is something wrong, ${retries++}` });
});

app.listen(PORT, () => console.log('listening on port:', PORT));

P.S.
endpoint: `${environment.apiUrl}/api/v1/videos/upload?uploadType=multipart`,
uploadType should not be used, it is only for the demo application.

from ngx-uploadx.

Chocobozzz avatar Chocobozzz commented on July 20, 2024

I cannot reproduce either, but it would be convenient to have a shouldRetry function in https://github.com/kukhariev/ngx-uploadx/blob/master/src/uploadx/lib/retry-handler.ts#L53 because in our use case an error 500 is considered as fatal.

from ngx-uploadx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.