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

Bug: An error occurred when requesting an interrupt #56

Open
dcbestwords opened this issue Oct 2, 2024 · 0 comments
Open

Bug: An error occurred when requesting an interrupt #56

dcbestwords opened this issue Oct 2, 2024 · 0 comments

Comments

@dcbestwords
Copy link

Bug Report

Current Behavior
When the upload request is interrupted during the upload of a file, a Parse Error message will be displayed. If you delete the file and upload it again, an operation not permitted message will be displayed.

Input Code

const Koa = require('koa');
const cors = require('@koa/cors');
const { bodyParser } = require('@koa/bodyparser');
const static = require('koa-static');
const multer = require('@koa/multer');
const Router = require('@koa/router');

const app = new Koa();
app.use(cors());
app.use(bodyParser({ jsonLimit: '50mb' }));
app.use(static('F://'));

const router = new Router();
const upload = multer({
  dest: 'F://新建文件夹',
  limits: undefined,
});
router.post('/upload', upload.single('file'), async (ctx) => {
  try {
    ctx.status = 200;
    ctx.body = {
      code: 200,
      msg: '文件上传成功',
    };
  } catch (err) {
    console.log('upload error:', err);
    ctx.status = 500;
  }
});

app.use(router.routes());
app.on('error', (err) => console.error('Request error:', err));
app.listen(9528, () => console.log('Server start on port 9528'));

Expected behavior/code
The program runs normally

Environment

  • Node/npm/yarn version: [Node 20.0.0/npm 9.6.4]
  • @koa/multer & koa version: [@koa/multer 3.0.2, @koa 2.15.3]
  • OS: [23H2, Windows 11]
  • Monorepo: [no]

Additional context/Screenshots
image
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