react-media-recorder icon indicating copy to clipboard operation
react-media-recorder copied to clipboard

Console error Uncaught (in promise) Error: There is already an encoder stored which handles exactly the same mime types. at Worker.<anonymous> (module.ts:49:1)

Open gwhizoftv opened this issue 2 years ago • 34 comments

Hi, Thank you for making this package! It gives this error when using the basic wrapper code:

import './App.css';
import { ReactMediaRecorder } from 'react-media-recorder'
 
function App() {
 return (
    <ReactMediaRecorder
       video
       render={({ status, startRecording, stopRecording, mediaBlobUrl }) => (
         <div>
          <p>{status}\</p>
          <button onClick={startRecording}>Start Recording</button>
          <button onClick={stopRecording}>Stop Recording</button>
          <video src={mediaBlobUrl} controls autoPlay loop />
         </div>
        )}
     />
   );
 }
 
 export default App;

My environment is:

  • Macos Monterey,
  • Chrome 103,
  • the project was created using npx create-react-app,
  • the package was installed with npm
  • dependencies from Package.json:
"dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-media-recorder": "^1.6.6",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"`

As you can see in the above code, I'm not setting any of the options available, especially the mimetype.

gwhizoftv avatar Jul 18 '22 17:07 gwhizoftv

I'm also facing same issue. record_issue

CodeFox1119 avatar Jul 25 '22 01:07 CodeFox1119

image same issue here... using next.js 12 version.

I resolved it, by removing some lines for wav codec support. (Of course, it is not a good way when you are to use wav codec)

useEffect(() => {
    const setup = async () => {
      await register(await connect());
    };
    setup();
  }, []);

Please refer to below issues. https://github.com/chrisguttandin/extendable-media-recorder/issues/645

It seems that an error occured as I call register() multiples times with the same encoder.

jaeyoungheo8697 avatar Jul 26 '22 06:07 jaeyoungheo8697

I'm also having this issue. The issue happens when I'm navigating between different pages in my application. I'm using hooks.

merttyilmaz avatar Jul 26 '22 09:07 merttyilmaz

Hi, me too have this issue. The issue happens when I'm navigating between different pages in my application. I'm using hooks.

pavlonsp avatar Aug 01 '22 09:08 pavlonsp

Same here using Nextjs

Component page:

  const RecordEventCreation = dynamic(
    () => import("../../components/Record/RecordEventCreation")
  );

Record component

  import { useReactMediaRecorder, StatusMessages} from 'react-media-recorder';

charlesjavelona avatar Aug 01 '22 15:08 charlesjavelona

i have this error when i use react-router and use history.push inside onRedirectCommand

freeday avatar Aug 02 '22 17:08 freeday

Hello everyone, I was facing the same issue. The most straightforward way to solve this is to remove the strict mode from your project.

JackCompass avatar Aug 08 '22 07:08 JackCompass

I have the same issue when using react-router. Removing strict does not work for those in CRA. At the moment, I imagine something is going on with a re-rendering. EDIT: I found indeed there was some excessive re-rendering in my app and that is something I have to look at as an aside, but a quick fix was moving it higher up the tree and the problem disappeared.

jessejamesrich avatar Aug 22 '22 21:08 jessejamesrich

Having the same issue as I'm re-using the hook multiple times on the same page. I don't want to drop strict mode and it doesn't solve the issue anyway for CRA, as @jessejamesrich pointed out.

I tried switching blobPropertyBag to {type: 'audio/mp3'} (from the default {type: 'audio/wav'}), though that had the same error. @0x006F would you be open to make the logic running in the useEffect optional? See https://github.com/0x006F/react-media-recorder/issues/105#issuecomment-1195057490

Related issue https://github.com/0x006F/react-media-recorder/issues/98

drummerjolev avatar Sep 28 '22 17:09 drummerjolev

I found this issue returned just recently as well. So I will be back to look at it here.

jessejamesrich avatar Sep 28 '22 17:09 jessejamesrich

I too am experiencing this issue

tochukwu19 avatar Oct 11 '22 20:10 tochukwu19

Same issue though mine I'm calling it inside a modal.

kalib-code avatar Oct 13 '22 09:10 kalib-code

Hi, me too have this issue. I'm using hooks. The issue happens when I'm navigating between different pages in my application and reload page.

bashtblrkin avatar Nov 15 '22 08:11 bashtblrkin

Same issue here as well. Called in a modal, using hooks (also Next)

treyholt avatar Nov 16 '22 01:11 treyholt

The encoder error went away for me on NextJS by downgrading to 1.6.5 npm i [email protected]

treyholt avatar Nov 16 '22 01:11 treyholt

Hey everyone,

I'm sorry, I've been away for a while and couldn't keep up on this. I really appreciate everyone's involvement in this, and of course your patience.

Read through the comments and related issues, and it feels like it's specific to NextJS or am I plain wrong? (or SSR in general).

If anyone has an open PR to solve, this, I'd really appreciate it. It'd take another week or two for me to settle down everything.

Once again, I appreciate everyone's patience. Thanks!

DeltaCircuit avatar Nov 19 '22 11:11 DeltaCircuit

The same thing happened to me today with nextjs13. As some comments previously said removing the 'strict mode' can make the error disappear. The problem occurs because the useEffect on line 84 (https://github.com/0x006F/react-media-recorder/blob/master/src/index.ts#L84) register the wav encoders every time the component is mounted. On some occasions (it can be with strict mode but also for other reasons such as re-rendering the parent component in the tree) the render ocurs 2 or more times and this causes an error. The problem is that it's not enough to interrupt the execution of the function in the unmount behavior, because under the hood it is registering the encoders with workers. I didn't find a simple way to call the worker and interrupt it. So i just wrapped the useEffect function in a try catch to work bypassing that problem. Also for those people who doesn't need audio maybe you can avoid to register the encoders. Here is my code with both things (try catch wrapper and audio verification before register encoders)

  useEffect(() => {
    const setup = async () => {
      try {
        audio && await register(await connect());
      } catch (error) {
        console.error(error)
      }
    };
    setup();
  }, []);

Faridmurzone avatar Nov 27 '22 22:11 Faridmurzone

Any update on this? It'd be nice to get a patch version out hehe

MarioArriaga92 avatar Dec 02 '22 20:12 MarioArriaga92

@Faridmurzone , thanks a lot for this, it fixed for me

pedrosimao avatar Jan 08 '23 22:01 pedrosimao

Anyone mind opening a PR to patch this? Thanks

gameveloster avatar Feb 02 '23 03:02 gameveloster

Change version to 1.4.0

AliverdiSultanli avatar Feb 10 '23 15:02 AliverdiSultanli

It seems that there might be a conflict with the npm versioning. Note: I'm not terribly familiar with publishing npm packages, so forgive me if I have this wrong. On npmjs.com, the package is on version 1.6.6, but on Github, the package is on version 1.4.0. It also looks like there is a different owner on npmjs.com, or @0x006F changed their username.

christopher-kapic avatar Feb 21 '23 17:02 christopher-kapic

I have forked this project and I am doing the bug fixes, you can use this package

https://www.npmjs.com/package/react-media-recorder-2

marefati110 avatar Mar 18 '23 16:03 marefati110

I have forked this project and I am doing the bug fixes, you can use this package

https://www.npmjs.com/package/react-media-recorder-2

That works like a charm :) <3

holyMolyTolli avatar Apr 10 '23 22:04 holyMolyTolli

I'm also having this issue

AtleMichaelSelberg avatar Apr 19 '23 00:04 AtleMichaelSelberg

I have forked this project and I am doing the bug fixes, you can use this package

https://www.npmjs.com/package/react-media-recorder-2

That's why you're the goat. ❤️

maktoobgar avatar May 10 '23 12:05 maktoobgar

How to download video from it as mp4 react media recorder

Marconoyet avatar Jul 16 '23 16:07 Marconoyet

How to download video from it as mp4 react media recorder

  <a
        href={mediaBlobUrl}
        download
      >
        Download
  </a>

or you can set the file name to something else (for example - demo.mp4):

 <a
       href={mediaBlobUrl}
       download = 'demo.mp4'
     >
       Download
 </a>

TomerBu avatar Jul 26 '23 13:07 TomerBu

https://www.npmjs.com/package/react-media-recorder-2 Yes, this is working well 😍

ijas-aslam avatar Jul 29 '23 17:07 ijas-aslam

@treyholt The encoder error went away for me on NextJS by downgrading to 1.6.5 npm i [email protected] ... this solution worked, also worked for me in ReactJS ... Thanks!

abhijeetvinkare avatar Aug 29 '23 02:08 abhijeetvinkare